rails_relations_fix 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -7,14 +7,14 @@ module ActiveRecord
7
7
  def self.define_callback_methods
8
8
  base = ActiveRecord::Base
9
9
  [:create, :update, :destroy].each do |method|
10
- # Due to using aliast_method_chain for methods like method_name_with_callbacks they are not reading from this file.
10
+ # Due to using aliast_method_chain for methods like method_name_with_callbacks they are not reading from this file.
11
11
  # They need to be reloaded.
12
12
  base.send :alias_method, method, "#{method}_without_callbacks".to_sym
13
13
  base.send :alias_method_chain, method, :callbacks
14
14
  end
15
15
  base.define_callbacks *NEW_CALLBACKS
16
16
  end
17
-
17
+
18
18
  def create_with_callbacks #:nodoc:
19
19
  return false if callback(:before_create) == false
20
20
  return false if callback(:before_add) == false if changed?
@@ -23,7 +23,7 @@ module ActiveRecord
23
23
  callback(:after_create)
24
24
  result
25
25
  end
26
-
26
+
27
27
  def update_with_callbacks(*args) #:nodoc:
28
28
  return false if callback(:before_update) == false
29
29
  return false if callback(:before_add) == false if changed?
@@ -32,7 +32,7 @@ module ActiveRecord
32
32
  callback(:after_update)
33
33
  result
34
34
  end
35
-
35
+
36
36
  def destroy_with_callbacks #:nodoc:
37
37
  return false if callback(:before_destroy) == false
38
38
  return false if callback(:before_remove) == false
@@ -41,24 +41,24 @@ module ActiveRecord
41
41
  callback(:after_destroy)
42
42
  result
43
43
  end
44
-
44
+
45
45
  def before_add() end #:nodoc:
46
46
  def after_add() end #:nodoc:
47
47
  def before_remove() end #:nodoc:
48
48
  def after_remove() end #:nodoc:
49
-
49
+
50
50
  end
51
-
51
+
52
52
  module Associations
53
53
  module ClassMethods
54
54
  def add_counter_cache_callbacks(reflection)
55
+
55
56
  cache_column = reflection.counter_cache_column
56
57
 
57
58
  method_name = "belongs_to_counter_cache_after_add_for_#{reflection.name}".to_sym
58
59
  define_method(method_name) do
60
+ association = self.subject_type.constantize.find(self.subject_id) rescue nil
59
61
 
60
- association = send(reflection.name, true) rescue nil
61
-
62
62
  if send("#{reflection.primary_key_name}_changed?") && send("#{reflection.primary_key_name}_change") != send("#{reflection.primary_key_name}_change").compact
63
63
  association.class.increment_counter(cache_column, association.id) unless association.nil?
64
64
  end
@@ -78,6 +78,6 @@ module ActiveRecord
78
78
  end
79
79
  end
80
80
  end
81
-
81
+
82
82
  end
83
83
 
@@ -1,50 +1,48 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_relations_fix}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stanis\305\202aw Kolarzowski"]
12
- s.date = %q{2010-02-15}
12
+ s.date = %q{2010-12-27}
13
13
  s.description = %q{Fix for 2 rails bugs. #3005 Counter_cache and polymorhic association. #3964 Not refreshing association after destroy}
14
14
  s.email = %q{stanislaw.kolarzowski@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/rails_relations_fix.rb",
27
- "lib/rails_relations_fix/association.rb",
28
- "lib/rails_relations_fix/counter_cache.rb",
29
- "rails_relations_fix.gemspec",
30
- "test/helper.rb",
31
- "test/test_rails_relations_fix.rb"
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/rails_relations_fix.rb",
26
+ "lib/rails_relations_fix/association.rb",
27
+ "lib/rails_relations_fix/counter_cache.rb",
28
+ "rails_relations_fix.gemspec",
29
+ "test/helper.rb",
30
+ "test/test_rails_relations_fix.rb"
32
31
  ]
33
32
  s.homepage = %q{http://github.com/staszek/rails_relations_fix}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
33
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.5}
34
+ s.rubygems_version = %q{1.3.7}
37
35
  s.summary = %q{Fix for 2 rails bugs}
38
36
  s.test_files = [
39
37
  "test/helper.rb",
40
- "test/test_rails_relations_fix.rb"
38
+ "test/test_rails_relations_fix.rb"
41
39
  ]
42
40
 
43
41
  if s.respond_to? :specification_version then
44
42
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
43
  s.specification_version = 3
46
44
 
47
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
46
  else
49
47
  end
50
48
  else
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_relations_fix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - "Stanis\xC5\x82aw Kolarzowski"
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-02-15 00:00:00 +01:00
18
+ date: 2010-12-27 00:00:00 +01:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -24,7 +30,6 @@ extra_rdoc_files:
24
30
  - README.rdoc
25
31
  files:
26
32
  - .document
27
- - .gitignore
28
33
  - LICENSE
29
34
  - README.rdoc
30
35
  - Rakefile
@@ -40,26 +45,32 @@ homepage: http://github.com/staszek/rails_relations_fix
40
45
  licenses: []
41
46
 
42
47
  post_install_message:
43
- rdoc_options:
44
- - --charset=UTF-8
48
+ rdoc_options: []
49
+
45
50
  require_paths:
46
51
  - lib
47
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
48
54
  requirements:
49
55
  - - ">="
50
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
51
60
  version: "0"
52
- version:
53
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
54
63
  requirements:
55
64
  - - ">="
56
65
  - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
57
69
  version: "0"
58
- version:
59
70
  requirements: []
60
71
 
61
72
  rubyforge_project:
62
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.7
63
74
  signing_key:
64
75
  specification_version: 3
65
76
  summary: Fix for 2 rails bugs
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC