acts_as_favoritor 4.0.0 → 4.0.1
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 +4 -4
- data/README.md +2 -2
- data/lib/acts_as_favoritor/favoritor.rb +4 -4
- data/lib/acts_as_favoritor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9a4ceadc5d7cd5517f8f4f6d234b5588f991e43271cf268be6df619400be3ac
|
4
|
+
data.tar.gz: 9aaa2da1aad9087ddd85fe0b9bc7454c27fba2d704fe3a63b314fae77861826f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f277da7298d714bb96c01c3899ba973d631b324164a6472730480a6d50cc70892d401725004377addc8d29287348a10954f034e813e2e7ad69d6f21f200cb3f0
|
7
|
+
data.tar.gz: 65e9de4bf1b195b9d831efa02a86e91f2248fc1e5629e9c729a98ab146351a38dd609290adebd48cef236bf605b2f92cc132ad2350c93e2fb68f9f9c86271752
|
data/README.md
CHANGED
@@ -259,11 +259,11 @@ You can configure acts_as_favoritor by passing a block to `configure`. This can
|
|
259
259
|
|
260
260
|
```ruby
|
261
261
|
ActsAsFavoritor.configure do |config|
|
262
|
-
config.default_scope =
|
262
|
+
config.default_scope = :follow
|
263
263
|
end
|
264
264
|
```
|
265
265
|
|
266
|
-
**`default_scope`** Specify your default scope. Takes a string. Defaults to
|
266
|
+
**`default_scope`** Specify your default scope. Takes a string. Defaults to `:favorite`. Learn more about scopes [here](#scopes).
|
267
267
|
|
268
268
|
**`cache`** Whether `acts_as_favoritor` uses caching or not. Takes a boolean. Defaults to `false`. Learn more about caching [here](#caching).
|
269
269
|
|
@@ -49,7 +49,7 @@ module ActsAsFavoritor
|
|
49
49
|
self.class.build_result_for_scopes scopes do |scope|
|
50
50
|
return nil if self == favoritable
|
51
51
|
|
52
|
-
inc_cache if ActsAsFavoritor.configuration.cache
|
52
|
+
inc_cache(scope) if ActsAsFavoritor.configuration.cache
|
53
53
|
|
54
54
|
favorites.for_favoritable(favoritable).send("#{scope}_list")
|
55
55
|
.first_or_create!
|
@@ -62,7 +62,7 @@ module ActsAsFavoritor
|
|
62
62
|
favorite_record = get_favorite(favoritable, scope)
|
63
63
|
return nil unless favorite_record.present?
|
64
64
|
|
65
|
-
dec_cache if ActsAsFavoritor.configuration.cache
|
65
|
+
dec_cache(scope) if ActsAsFavoritor.configuration.cache
|
66
66
|
favorite_record.destroy!
|
67
67
|
end
|
68
68
|
end
|
@@ -129,7 +129,7 @@ module ActsAsFavoritor
|
|
129
129
|
end
|
130
130
|
|
131
131
|
# rubocop:disable Metrics/AbcSize
|
132
|
-
def inc_cache
|
132
|
+
def inc_cache(scope)
|
133
133
|
favoritor_score[scope] = (favoritor_score[scope] || 0) + 1
|
134
134
|
favoritor_total[scope] = (favoritor_total[scope] || 0) + 1
|
135
135
|
save!
|
@@ -141,7 +141,7 @@ module ActsAsFavoritor
|
|
141
141
|
favoritable.save!
|
142
142
|
end
|
143
143
|
|
144
|
-
def dec_cache
|
144
|
+
def dec_cache(scope)
|
145
145
|
favoritor_score[scope] = (favoritor_score[scope] || 0) - 1
|
146
146
|
favoritor_score.delete(scope) unless favoritor_score[scope].positive?
|
147
147
|
save!
|
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: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|