acts_as_favoritor 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06cf69692e09e9376711dbfde7d639149600bfc6
4
- data.tar.gz: 760b69362bdbc3e8803c91df0216d5a2c75656ba
3
+ metadata.gz: 36345549bdc01f5e0004374e85664bf0a733b1c1
4
+ data.tar.gz: 598c7e15c8c5db68774c09b4189910038c7e58f7
5
5
  SHA512:
6
- metadata.gz: 1a24a70eb7d95a1e8803a5fad40050e77a6eb0545a0062316e99f7bacca82ccf5f33bac876896edb587400da2c675380ea7077cc0fa0800dafbf70023508485b
7
- data.tar.gz: cb865f52e429ca810f4bc7ad1fb4c61f6f38c7350ca273b1732b284faf62dce817039b6ef43d9c9a7a03b34ea11252f5b46f9e342d3c86513c6a5da4935c3e7c
6
+ metadata.gz: 3db17c17ecda44b19ab834d61d8b27008ee1ca799ae382a6a354afb9b73c5fc8a02cb3e66da32802d46e8ec2f698293928db050143c7a507f97929960ae803fc
7
+ data.tar.gz: ecf17edd2f5e9097f32b906d426abbe952109cb4425f88a5f989d199c085172f214a694b8d1337befe38e94ff22bbd59b1d4678e6070a703123645f8e5dd8ee9
@@ -4,6 +4,11 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 1.5.0 - 2017-09-02
8
+
9
+ * features
10
+ * access scope specific caches through methods
11
+
7
12
  ### 1.4.0 - 2017-09-01
8
13
 
9
14
  * features
data/README.md CHANGED
@@ -281,14 +281,14 @@ For that you need to add some database columns:
281
281
  *acts_as_favoritor*
282
282
 
283
283
  ```ruby
284
- add_column :users, :favoritor_cache, :text, default: {}.to_yaml, null: false
284
+ add_column :users, :favoritor_cache, :text
285
285
  ```
286
286
 
287
287
  *acts_as_favoritable*
288
288
 
289
289
  ```ruby
290
- add_column :users, :favoritable_cache, :text, default: {}.to_yaml, null: false
291
- add_column :books, :favoritable_cache, :text, default: {}.to_yaml, null: false
290
+ add_column :users, :favoritable_cache, :text
291
+ add_column :books, :favoritable_cache, :text
292
292
  ```
293
293
 
294
294
  Caches are stored as hashes with scopes as keys:
@@ -301,6 +301,16 @@ book.favoritable_cache # => { favorite: 1 }
301
301
 
302
302
  **Note:** Only scopes who have favorites are included.
303
303
 
304
+ `acts_as_favoritor` makes it even simpler to access cached values:
305
+
306
+ ```ruby
307
+ user.favoritor_favorite_cache # => 1
308
+ second_user.favoritable_follow_cache # => 1
309
+ book.favoritable_favorite_cache # => 1
310
+ ```
311
+
312
+ **Note:** These methods are available for every scope you are using.
313
+
304
314
  ---
305
315
 
306
316
  ## Configuration
@@ -311,7 +321,9 @@ When you delete this file, all settings will rollback to their defaults. You can
311
321
 
312
322
  Currently supported Settings:
313
323
 
314
- **default_scope:** Specify your default scope. Learn more about scopes here: https://github.com/slooob/acts_as_favoritor#scopes
324
+ **default_scope:** Specify your default scope. Learn more about scopes [here](#scopes).
325
+
326
+ **cache:** Whether `acts_as_favoritor` uses cache or not. Learn more about caching [here](#caching).
315
327
 
316
328
  If you have an idea for a new setting, propose it by creating a new [issue](https://github.com/slooob/acts_as_favoritor/issues).
317
329
 
@@ -94,6 +94,10 @@ module ActsAsFavoritor #:nodoc:
94
94
  favoritors_by_type_count $1.singularize.classify
95
95
  elsif m.to_s[/(.+)_favoritors/]
96
96
  favoritors_by_type $1.singularize.classify
97
+ elsif m.to_s[/favoritable_(.+)_score/]
98
+ favoritable_score[$1.singularize.classify] if ActsAsFavoritor.cache
99
+ elsif m.to_s[/favoritable_(.+)_total/]
100
+ favoritable_total[$1.singularize.classify] if ActsAsFavoritor.cache
97
101
  else
98
102
  super
99
103
  end
@@ -296,6 +296,10 @@ module ActsAsFavoritor #:nodoc:
296
296
  favorited_by_type_count $1.singularize.classify
297
297
  elsif m.to_s[/favorited_(.+)/]
298
298
  favorited_by_type $1.singularize.classify
299
+ elsif m.to_s[/favoritor_(.+)_score/]
300
+ favoritor_score[$1.singularize.classify] if ActsAsFavoritor.cache
301
+ elsif m.to_s[/favoritor_(.+)_total/]
302
+ favoritor_total[$1.singularize.classify] if ActsAsFavoritor.cache
299
303
  else
300
304
  super
301
305
  end
@@ -1,5 +1,5 @@
1
1
  module ActsAsFavoritor
2
2
 
3
- VERSION = '1.4.0'
3
+ VERSION = '1.5.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_favoritor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Slooob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-01 00:00:00.000000000 Z
11
+ date: 2017-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord