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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +16 -4
- data/lib/acts_as_favoritor/favoritable.rb +4 -0
- data/lib/acts_as_favoritor/favoritor.rb +4 -0
- data/lib/acts_as_favoritor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36345549bdc01f5e0004374e85664bf0a733b1c1
|
4
|
+
data.tar.gz: 598c7e15c8c5db68774c09b4189910038c7e58f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3db17c17ecda44b19ab834d61d8b27008ee1ca799ae382a6a354afb9b73c5fc8a02cb3e66da32802d46e8ec2f698293928db050143c7a507f97929960ae803fc
|
7
|
+
data.tar.gz: ecf17edd2f5e9097f32b906d426abbe952109cb4425f88a5f989d199c085172f214a694b8d1337befe38e94ff22bbd59b1d4678e6070a703123645f8e5dd8ee9
|
data/CHANGELOG.md
CHANGED
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
|
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
|
291
|
-
add_column :books, :favoritable_cache, :text
|
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
|
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
|
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
|
+
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-
|
11
|
+
date: 2017-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|