acts_as_favoritor 1.3.2 → 1.4.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: 14b98ac10e904c740a31afb1a221de5db6d0bca2
4
- data.tar.gz: bb136d5035521b41db3cd888a96bcc991c405862
3
+ metadata.gz: 06cf69692e09e9376711dbfde7d639149600bfc6
4
+ data.tar.gz: 760b69362bdbc3e8803c91df0216d5a2c75656ba
5
5
  SHA512:
6
- metadata.gz: ee95fe8c8bd1528dea8a57f6fa9c992c5ff449c140fbdf03f6949514e7a6e10d99e1775fb3864c902c6b0090d74ee2c273929923c6468882db2e988e3a42c8ab
7
- data.tar.gz: 114e8d8ba89bc8f4f0257847eb7bd8720367088e32c94ea90569186a28dc96ce36f7534ffdf8600c9295706a144bf35c2bf8a3541d91a41e8a6467aa4a1ab6a5
6
+ metadata.gz: 1a24a70eb7d95a1e8803a5fad40050e77a6eb0545a0062316e99f7bacca82ccf5f33bac876896edb587400da2c675380ea7077cc0fa0800dafbf70023508485b
7
+ data.tar.gz: cb865f52e429ca810f4bc7ad1fb4c61f6f38c7350ca273b1732b284faf62dce817039b6ef43d9c9a7a03b34ea11252f5b46f9e342d3c86513c6a5da4935c3e7c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 1.4.0 - 2017-09-01
8
+
9
+ * features
10
+ * update caching functionality to include `score` & `total`
11
+
7
12
  ### 1.3.2 - 2017-08-31
8
13
 
9
14
  * features
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  `acts_as_favoritor` is a Rubygem to allow any ActiveRecord model to associate any other model including the option for multiple relationships per association with scopes.
6
6
 
7
- You are able to differentiate followers, favorites, watchers, votes and whatever else you can imagine through a single relationship. This is accomplished by a double polymorphic relationship on the Favorite model. There is also built in support for blocking/un-blocking favorite records.
7
+ You are able to differentiate followers, favorites, watchers, votes and whatever else you can imagine through a single relationship. This is accomplished by a double polymorphic relationship on the Favorite model. There is also built in support for blocking/un-blocking favorite records as well as caching.
8
8
 
9
9
  ---
10
10
 
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.version = ActsAsFavoritor::VERSION
7
7
  gem.platform = Gem::Platform::RUBY
8
8
  gem.summary = 'A Rubygem to add Favorite, Follow, Vote, etc. functionality to ActiveRecord models'
9
- gem.description = 'acts_as_favoritor is a Rubygem to allow any ActiveRecord model to associate any other model including the option for multiple relationships per association with scopes. You are able to differentiate followers, favorites, watchers, votes and whatever else you can imagine through a single relationship. This is accomplished by a double polymorphic relationship on the Favorite model. There is also built in support for blocking/un-blocking favorite records.'
9
+ gem.description = 'acts_as_favoritor is a Rubygem to allow any ActiveRecord model to associate any other model including the option for multiple relationships per association with scopes. You are able to differentiate followers, favorites, watchers, votes and whatever else you can imagine through a single relationship. This is accomplished by a double polymorphic relationship on the Favorite model. There is also built in support for blocking/un-blocking favorite records as well as caching.'
10
10
  gem.authors = 'Slooob'
11
11
  gem.email = 'developer@slooob.com'
12
12
  gem.homepage = 'https://developer.slooob.com/open-source'
@@ -104,9 +104,11 @@ module ActsAsFavoritor #:nodoc:
104
104
  results = {}
105
105
  options[:scope].each do |scope|
106
106
  if ActsAsFavoritor.cache
107
- self.favoritor_cache[scope] = self.favoritor_cache[scope] + 1 || 1
107
+ self.favoritor_score[scope] = self.favoritor_score[scope] + 1 || 1
108
+ self.favoritor_total[scope] = self.favoritor_total[scope] + 1 || 1
108
109
  self.save!
109
- favoritable.favoritable_cache[scope] = favoritable.favoritable_cache[scope] + 1 || 1
110
+ favoritable.favoritable_score[scope] = favoritable.favoritable_score[scope] + 1 || 1
111
+ favoritable.favoritable_total[scope] = favoritable.favoritable_total[scope] + 1 || 1
110
112
  favoritable.save!
111
113
  end
112
114
  if self != favoritable && scope != 'all'
@@ -117,9 +119,11 @@ module ActsAsFavoritor #:nodoc:
117
119
  return results
118
120
  else
119
121
  if ActsAsFavoritor.cache
120
- self.favoritor_cache[options[:scope]] = self.favoritor_cache[options[:scope]] + 1 || 1
122
+ self.favoritor_score[options[:scope]] = self.favoritor_score[options[:scope]] + 1 || 1
123
+ self.favoritor_total[options[:scope]] = self.favoritor_total[options[:scope]] + 1 || 1
121
124
  self.save!
122
- favoritable.favoritable_cache[options[:scope]] = favoritable.favoritable_cache[options[:scope]] + 1 || 1
125
+ favoritable.favoritable_score[options[:scope]] = favoritable.favoritable_score[options[:scope]] + 1 || 1
126
+ favoritable.favoritable_total[options[:scope]] = favoritable.favoritable_total[options[:scope]] + 1 || 1
123
127
  favoritable.save!
124
128
  end
125
129
  if self != favoritable && options[:scope] != 'all'
@@ -138,11 +142,11 @@ module ActsAsFavoritor #:nodoc:
138
142
  results = {}
139
143
  options[:scope].each do |scope|
140
144
  if ActsAsFavoritor.cache
141
- self.favoritor_cache[scope] = self.favoritor_cache[scope] - 1
142
- self.favoritor_cache.delete(scope) unless self.favoritor_cache[scope] > 0
145
+ self.favoritor_score[scope] = self.favoritor_score[scope] - 1
146
+ self.favoritor_score.delete(scope) unless self.favoritor_score[scope] > 0
143
147
  self.save!
144
- favoritable.favoritable_cache[scope] = favoritable.favoritable_cache[scope] - 1
145
- favoritable.favoritable_cache.delete(scope) unless favoritable.favoritable_cache[scope] > 0
148
+ favoritable.favoritable_score[scope] = favoritable.favoritable_score[scope] - 1
149
+ favoritable.favoritable_score.delete(scope) unless favoritable.favoritable_score[scope] > 0
146
150
  favoritable.save!
147
151
  end
148
152
  if favorite = get_favorite(favoritable, scope: scope, multiple_scopes: false)
@@ -152,11 +156,11 @@ module ActsAsFavoritor #:nodoc:
152
156
  return results
153
157
  else
154
158
  if ActsAsFavoritor.cache
155
- self.favoritor_cache[options[:scope]] = self.favoritor_cache[options[:scope]] - 1
156
- self.favoritor_cache.delete(options[:scope]) unless self.favoritor_cache[options[:scope]] > 0
159
+ self.favoritor_score[options[:scope]] = self.favoritor_score[options[:scope]] - 1
160
+ self.favoritor_score.delete(options[:scope]) unless self.favoritor_score[options[:scope]] > 0
157
161
  self.save!
158
- favoritable.favoritable_cache[options[:scope]] = favoritable.favoritable_cache[options[:scope]] - 1
159
- favoritable.favoritable_cache.delete(options[:scope]) unless favoritable.favoritable_cache[options[:scope]] > 0
162
+ favoritable.favoritable_score[options[:scope]] = favoritable.favoritable_score[options[:scope]] - 1
163
+ favoritable.favoritable_score.delete(options[:scope]) unless favoritable.favoritable_score[options[:scope]] > 0
160
164
  favoritable.save!
161
165
  end
162
166
  if favorite = get_favorite(favoritable, scope: options[:scope], multiple_scopes: false)
@@ -1,5 +1,5 @@
1
1
  module ActsAsFavoritor
2
2
 
3
- VERSION = '1.3.2'
3
+ VERSION = '1.4.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.3.2
4
+ version: 1.4.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-08-31 00:00:00.000000000 Z
11
+ date: 2017-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -113,7 +113,7 @@ description: acts_as_favoritor is a Rubygem to allow any ActiveRecord model to a
113
113
  with scopes. You are able to differentiate followers, favorites, watchers, votes
114
114
  and whatever else you can imagine through a single relationship. This is accomplished
115
115
  by a double polymorphic relationship on the Favorite model. There is also built
116
- in support for blocking/un-blocking favorite records.
116
+ in support for blocking/un-blocking favorite records as well as caching.
117
117
  email: developer@slooob.com
118
118
  executables: []
119
119
  extensions: []