acts_as_favoritor 4.0.0 → 4.0.1

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
  SHA256:
3
- metadata.gz: 688cadb90a8c8e5fb799d2973aaffa6345e756456640fdba0c3d9f44715b92c2
4
- data.tar.gz: 3b9a838d6fdf2a011494ca5822ca8f54290738d1a81ddb82f36e051f8f3630cc
3
+ metadata.gz: c9a4ceadc5d7cd5517f8f4f6d234b5588f991e43271cf268be6df619400be3ac
4
+ data.tar.gz: 9aaa2da1aad9087ddd85fe0b9bc7454c27fba2d704fe3a63b314fae77861826f
5
5
  SHA512:
6
- metadata.gz: c1a3319925be822442579ec4d022b454b52649b5a95fa5949fdd7498420bb38038889136bb39c2da96f5511713a398eaf3a372a578ad4c8b6d1edd9089188ff5
7
- data.tar.gz: 52f518e8ab2d8c66c6fdd47f3bc57329745c3cdf28bd1f3ac41b13b3214d4d8ce9bad2549415b3098326437ec2747d90baf99c27411973991adcc82755ac79e2
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 = 'follow'
262
+ config.default_scope = :follow
263
263
  end
264
264
  ```
265
265
 
266
- **`default_scope`** Specify your default scope. Takes a string. Defaults to `'favorite'`. Learn more about scopes [here](#scopes).
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!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActsAsFavoritor
4
- VERSION = '4.0.0'
4
+ VERSION = '4.0.1'
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: 4.0.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-05 00:00:00.000000000 Z
11
+ date: 2019-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord