custom_counter_cache 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTEwMjdiMDFhMjNjOGQwMDIwZjU4YmMxODU3NjA4MTVlZDdiYjVjZA==
5
+ data.tar.gz: !binary |-
6
+ ZDJjOGYyYWFiMWQ5ZGM2M2Y4NDc3ZTIxMmU4NDIwZjVkN2FjMGIwYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjQzYjAyZTJmZDMyODczNjE3NzM2MjViZDRlN2U1OWYzNzY4NWNlMDVmM2Fi
10
+ ZTEyM2U1YzA1N2IzNThhYzk5OTJiZjkxZGEzZTE1ZDU4YTg2NWRkNGM2YmEz
11
+ YzAyZGUzNGFiMTZmN2Q5NjA5NDE2Yjc5Y2E4YjBlMThmOTMwM2Y=
12
+ data.tar.gz: !binary |-
13
+ YjNlMDU5MjYxOGQ5ZDMyMzMyNmJjNTRiNmEwMDc5OGQ2MDNjYTNkOGZmYmFk
14
+ NjUyZmY5YzdjZWVlOWJhODY3ZjFjZTQ1MWUzMTFjMzUwNzEyMDE4OGZmMGI2
15
+ YzcxNTQzNGZjNzU5OWMyNDdiOGY4OWU0NWU5NjNlY2Q4OTQwMjQ=
@@ -1,11 +1,11 @@
1
1
  module CustomCounterCache::Model
2
-
2
+
3
3
  def self.included(base)
4
4
  base.extend ActsAsMethods
5
5
  end
6
-
6
+
7
7
  module ActsAsMethods
8
-
8
+
9
9
  def define_counter_cache(cache_column, &block)
10
10
  # counter accessors
11
11
  unless column_names.include?(cache_column) # Object.const_defined?(:Counter)
@@ -28,10 +28,10 @@ module CustomCounterCache::Model
28
28
  end
29
29
  # counter update method
30
30
  define_method "update_#{cache_column}" do
31
- update_attribute cache_column, block.call(self)
31
+ send "#{cache_column}=", block.call(self)
32
32
  end
33
33
  end
34
-
34
+
35
35
  def update_counter_cache(association, cache_column, options = {})
36
36
  association = association.to_sym
37
37
  cache_column = cache_column.to_sym
@@ -41,7 +41,7 @@ module CustomCounterCache::Model
41
41
  # define callback
42
42
  define_method method_name do
43
43
  # update old association
44
- if send("#{foreign_key}_changed?") || ( respond_to?("#{association}_type") && send("#{association}_type_changed?") )
44
+ if send("#{foreign_key}_changed?") || ( !respond_to?("#{association}_type") || send("#{association}_type_changed?") )
45
45
  old_id = send("#{foreign_key}_was")
46
46
  klass = if reflection.options[:polymorphic]
47
47
  ( send("#{association}_type_was") || send("#{association}_type") ).constantize
@@ -62,9 +62,9 @@ module CustomCounterCache::Model
62
62
  after_update method_name, :if => options[:if]
63
63
  after_destroy method_name, :if => options[:if]
64
64
  end
65
-
65
+
66
66
  end
67
-
67
+
68
68
  end
69
69
 
70
70
  ActiveRecord::Base.send :include, CustomCounterCache::Model
@@ -1,5 +1,5 @@
1
1
  module CustomCounterCache
2
-
3
- VERSION = '0.0.6'
4
-
5
- end
2
+
3
+ VERSION = '0.0.7'
4
+
5
+ end
metadata CHANGED
@@ -1,59 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: custom_counter_cache
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Cedric Howe
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-08-28 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: rails
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 5
28
- segments:
29
- - 3
30
- version: "3"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
31
20
  type: :runtime
32
- requirement: *id001
33
21
  prerelease: false
34
- - !ruby/object:Gem::Dependency
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
35
28
  name: sqlite3
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
- none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
45
34
  type: :development
46
- requirement: *id002
47
35
  prerelease: false
48
- description: ""
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: ''
49
42
  email: cedric@howe.net
50
43
  executables: []
51
-
52
44
  extensions: []
53
-
54
45
  extra_rdoc_files: []
55
-
56
- files:
46
+ files:
57
47
  - lib/custom_counter_cache/model.rb
58
48
  - lib/custom_counter_cache/version.rb
59
49
  - lib/custom_counter_cache.rb
@@ -61,39 +51,28 @@ files:
61
51
  - test/test_helper.rb
62
52
  homepage: http://github.com/cedric/custom_counter_cache/
63
53
  licenses: []
64
-
54
+ metadata: {}
65
55
  post_install_message:
66
56
  rdoc_options: []
67
-
68
- require_paths:
57
+ require_paths:
69
58
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
79
- required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 23
85
- segments:
86
- - 1
87
- - 3
88
- - 6
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
89
68
  version: 1.3.6
90
69
  requirements: []
91
-
92
70
  rubyforge_project: custom_counter_cache
93
- rubygems_version: 1.8.24
71
+ rubygems_version: 2.0.3
94
72
  signing_key:
95
- specification_version: 3
96
- summary: Custom counter_cache functionality that supports conditions and multiple models.
97
- test_files:
73
+ specification_version: 4
74
+ summary: Custom counter_cache functionality that supports conditions and multiple
75
+ models.
76
+ test_files:
98
77
  - test/counter_test.rb
99
78
  - test/test_helper.rb