custom_counter_cache 0.1.9 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5ed286dea2fac6964d0d8dabee7e20ae56885e7
4
- data.tar.gz: cd65698b7836b912491fda90c9b4a64ea736c5aa
3
+ metadata.gz: a0df4c855c8d546d5ec7f81e536e317b1d222d53
4
+ data.tar.gz: 16859fbe11a54eb4aabdf53aadc9709e8355a8a7
5
5
  SHA512:
6
- metadata.gz: 1074d685ce04e2a7d823a419ab356dc734d0b79e5582276cbc4ad3bac60dd0728486434f64c19da3a09008e7435b217dda4d56b4e2230646c688d910855b0292
7
- data.tar.gz: 437d0d97666cc51fd1da3da23ebb6fa68d95181677ce58d4efb0ed6279e88fc554a8ed8e0d058201927ea72713b84e038fe714e3d7ce44e94193b33f785c4e43
6
+ metadata.gz: 6797bf2591cd0d5926a3f6bb2021f14929ef6f52aac6771caff65093639983439136caf3c499887328744c796b57c43fa431d59d455bbad693613510004dd974
7
+ data.tar.gz: 91bdf24d3740327dce1cc354b4bf34e36421a19dcd83f832309109e7671a36e696ddcb7acbec7c0a12d6dce625a4d35e31adf799ce5511340ee8e757eb7b475a
@@ -81,5 +81,3 @@ module CustomCounterCache::Model
81
81
  end
82
82
  end
83
83
  end
84
-
85
- ActiveRecord::Base.send :include, CustomCounterCache::Model
@@ -1,5 +1,5 @@
1
1
  module CustomCounterCache
2
2
 
3
- VERSION = '0.1.9'
3
+ VERSION = '0.2.0'
4
4
 
5
5
  end
data/test/test_helper.rb CHANGED
@@ -39,14 +39,19 @@ ActiveRecord::Schema.define(version: 1) do
39
39
  end
40
40
  end
41
41
 
42
- class User < ActiveRecord::Base
42
+ class ApplicationRecord < ActiveRecord::Base
43
+ self.abstract_class = true
44
+ include CustomCounterCache::Model
45
+ end
46
+
47
+ class User < ApplicationRecord
43
48
  has_many :articles, dependent: :destroy
44
49
  define_counter_cache :published_count do |user|
45
50
  user.articles.where(articles: { state: 'published' }).count
46
51
  end
47
52
  end
48
53
 
49
- class Article < ActiveRecord::Base
54
+ class Article < ApplicationRecord
50
55
  belongs_to :user
51
56
  update_counter_cache :user, :published_count, if: Proc.new { |article| article.state_changed? }
52
57
  has_many :comments, as: :commentable, dependent: :destroy
@@ -55,23 +60,23 @@ class Article < ActiveRecord::Base
55
60
  end
56
61
  end
57
62
 
58
- class Comment < ActiveRecord::Base
63
+ class Comment < ApplicationRecord
59
64
  belongs_to :commentable, polymorphic: true
60
65
  update_counter_cache :commentable, :comments_count, if: Proc.new { |comment| comment.state_changed? }
61
66
  end
62
67
 
63
- class Counter < ActiveRecord::Base
68
+ class Counter < ApplicationRecord
64
69
  belongs_to :countable, polymorphic: true
65
70
  end
66
71
 
67
- class Box < ActiveRecord::Base
72
+ class Box < ApplicationRecord
68
73
  has_many :balls
69
74
  define_counter_cache :green_balls_count do |box|
70
75
  box.balls.green.count
71
76
  end
72
77
  end
73
78
 
74
- class Ball < ActiveRecord::Base
79
+ class Ball < ApplicationRecord
75
80
  belongs_to :box
76
81
  scope :green, lambda { where(color: 'green') }
77
82
  update_counter_cache :box, :green_balls_count, if: Proc.new { |ball| ball.color_changed? }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_counter_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cedric Howe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-20 00:00:00.000000000 Z
11
+ date: 2017-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version: 1.3.6
70
70
  requirements: []
71
71
  rubyforge_project: custom_counter_cache
72
- rubygems_version: 2.4.5
72
+ rubygems_version: 2.6.11
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Custom counter_cache functionality that supports conditions and multiple