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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/acts_as_favoritor.gemspec +1 -1
- data/lib/acts_as_favoritor/favoritor.rb +16 -12
- data/lib/acts_as_favoritor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06cf69692e09e9376711dbfde7d639149600bfc6
|
4
|
+
data.tar.gz: 760b69362bdbc3e8803c91df0216d5a2c75656ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a24a70eb7d95a1e8803a5fad40050e77a6eb0545a0062316e99f7bacca82ccf5f33bac876896edb587400da2c675380ea7077cc0fa0800dafbf70023508485b
|
7
|
+
data.tar.gz: cb865f52e429ca810f4bc7ad1fb4c61f6f38c7350ca273b1732b284faf62dce817039b6ef43d9c9a7a03b34ea11252f5b46f9e342d3c86513c6a5da4935c3e7c
|
data/CHANGELOG.md
CHANGED
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
|
|
data/acts_as_favoritor.gemspec
CHANGED
@@ -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.
|
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.
|
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.
|
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.
|
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.
|
142
|
-
self.
|
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.
|
145
|
-
favoritable.
|
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.
|
156
|
-
self.
|
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.
|
159
|
-
favoritable.
|
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)
|
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.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-
|
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: []
|