mongoid-likeable 4.0 → 4.1
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/lib/mongoid/likeable.rb +8 -13
- data/mongoid-likeable.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7ab27bc064a7dcef21812624431d8753ab09468
|
4
|
+
data.tar.gz: 6fdb93ff39733743b70f696a6fa4164b72beae29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e13db4dc2662872836dec79c155feaa3111645c1c07b133768007262d27bcca7bc1f408821d2b918fffab34bc487f41ff7b5a498549e984f31ed313e4377653
|
7
|
+
data.tar.gz: 25933c7334d8786104a9ada57df4f71fdbd2adc0a5c0d07062d96fc21537e6be152db45dda0fe10ce6d60c69857329236c5e385eaf9d0698be789df42fc2d1d7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/mongoid/likeable.rb
CHANGED
@@ -6,8 +6,6 @@ module Mongoid
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
LIKEABLE_MUTEX = Mutex.new
|
10
|
-
|
11
9
|
field :likes, type: Integer, default: 0
|
12
10
|
field :likers, type: Array, default: []
|
13
11
|
end
|
@@ -15,21 +13,15 @@ module Mongoid
|
|
15
13
|
def like(liker)
|
16
14
|
id = liker_id(liker)
|
17
15
|
return if liked? id
|
18
|
-
|
19
|
-
|
20
|
-
push :likers, id
|
21
|
-
touch
|
22
|
-
end
|
16
|
+
push :likers, id
|
17
|
+
update_likers
|
23
18
|
end
|
24
19
|
|
25
20
|
def unlike(liker)
|
26
21
|
id = liker_id(liker)
|
27
22
|
return unless liked? id
|
28
|
-
|
29
|
-
|
30
|
-
pull :likers, id
|
31
|
-
touch
|
32
|
-
end
|
23
|
+
pull :likers, id
|
24
|
+
update_likers
|
33
25
|
end
|
34
26
|
|
35
27
|
def liked?(liker)
|
@@ -38,7 +30,6 @@ module Mongoid
|
|
38
30
|
end
|
39
31
|
|
40
32
|
private
|
41
|
-
|
42
33
|
def liker_id(liker)
|
43
34
|
if liker.respond_to?(:_id)
|
44
35
|
liker._id
|
@@ -46,5 +37,9 @@ module Mongoid
|
|
46
37
|
liker
|
47
38
|
end
|
48
39
|
end
|
40
|
+
|
41
|
+
def update_likers
|
42
|
+
update_attribute :likes, likers.size
|
43
|
+
end
|
49
44
|
end
|
50
45
|
end
|
data/mongoid-likeable.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'mongoid-likeable'
|
6
|
-
s.version = '4.
|
6
|
+
s.version = '4.1'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ['Diowa']
|
9
9
|
s.email = ['dev@diowa.com']
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rubyforge_project = 'mongoid-likeable'
|
15
15
|
|
16
|
-
s.add_dependency 'mongoid', '~> 3.1.
|
16
|
+
s.add_dependency 'mongoid', '~> 3.1.3'
|
17
17
|
|
18
18
|
s.add_development_dependency 'database_cleaner'
|
19
19
|
s.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-likeable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '4.
|
4
|
+
version: '4.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diowa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.1.
|
19
|
+
version: 3.1.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.1.
|
26
|
+
version: 3.1.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: database_cleaner
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|