mongoid_followable 0.1.1 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.idea/workspace.xml +58 -38
- data/README.rdoc +28 -7
- data/lib/mongoid_followable/followable.rb +36 -0
- data/lib/mongoid_followable/follower.rb +44 -2
- data/lib/mongoid_followable/version.rb +1 -1
- data/mongoid_followable.gemspec +1 -1
- data/spec/mongoid/followable_spec.rb +8 -0
- metadata +3 -32
data/.idea/workspace.xml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<project version="4">
|
3
3
|
<component name="ChangeListManager">
|
4
|
-
<list default="true" id="90bdec60-890b-4083-b05d-2f665a1f4d70" name="Default" comment=""
|
5
|
-
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lib/mongoid_followable/follower.rb" />
|
6
|
-
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
|
7
|
-
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
8
|
-
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/mongoid_followable.rb" afterPath="$PROJECT_DIR$/lib/mongoid_followable.rb" />
|
9
|
-
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/mongoid_followable/followable.rb" afterPath="$PROJECT_DIR$/lib/mongoid_followable/followable.rb" />
|
10
|
-
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/mongoid_followable/version.rb" afterPath="$PROJECT_DIR$/lib/mongoid_followable/version.rb" />
|
11
|
-
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/spec/models/user.rb" afterPath="$PROJECT_DIR$/spec/models/user.rb" />
|
12
|
-
</list>
|
4
|
+
<list default="true" id="90bdec60-890b-4083-b05d-2f665a1f4d70" name="Default" comment="" />
|
13
5
|
<ignored path="mongoid_followable.iws" />
|
14
6
|
<ignored path=".idea/workspace.xml" />
|
15
7
|
<option name="TRACKING_ENABLED" value="true" />
|
@@ -32,10 +24,10 @@
|
|
32
24
|
</component>
|
33
25
|
<component name="FileEditorManager">
|
34
26
|
<leaf>
|
35
|
-
<file leaf-file-name="
|
36
|
-
<entry file="file://$PROJECT_DIR$/
|
27
|
+
<file leaf-file-name="README.rdoc" pinned="false" current="true" current-in-tab="true">
|
28
|
+
<entry file="file://$PROJECT_DIR$/README.rdoc">
|
37
29
|
<provider selected="true" editor-type-id="text-editor">
|
38
|
-
<state line="
|
30
|
+
<state line="26" column="50" selection-start="693" selection-end="693" vertical-scroll-proportion="0.53846157">
|
39
31
|
<folding />
|
40
32
|
</state>
|
41
33
|
</provider>
|
@@ -62,13 +54,14 @@
|
|
62
54
|
<option value="$PROJECT_DIR$/lib/generators/mongoid_followable/install_generator.rb" />
|
63
55
|
<option value="$PROJECT_DIR$/spec/spec_helper.rb" />
|
64
56
|
<option value="$PROJECT_DIR$/app/models/follow.rb" />
|
65
|
-
<option value="$PROJECT_DIR$/spec/mongoid/followable_spec.rb" />
|
66
|
-
<option value="$PROJECT_DIR$/mongoid_followable.gemspec" />
|
67
|
-
<option value="$PROJECT_DIR$/lib/mongoid_followable/follower.rb" />
|
68
|
-
<option value="$PROJECT_DIR$/lib/mongoid_followable/followable.rb" />
|
69
57
|
<option value="$PROJECT_DIR$/lib/mongoid_followable.rb" />
|
70
58
|
<option value="$PROJECT_DIR$/spec/models/user.rb" />
|
59
|
+
<option value="$PROJECT_DIR$/spec/mongoid/followable_spec.rb" />
|
71
60
|
<option value="$PROJECT_DIR$/lib/mongoid_followable/version.rb" />
|
61
|
+
<option value="$PROJECT_DIR$/mongoid_followable.gemspec" />
|
62
|
+
<option value="$PROJECT_DIR$/lib/mongoid_followable/followable.rb" />
|
63
|
+
<option value="$PROJECT_DIR$/lib/mongoid_followable/follower.rb" />
|
64
|
+
<option value="$PROJECT_DIR$/README.rdoc" />
|
72
65
|
</list>
|
73
66
|
</option>
|
74
67
|
</component>
|
@@ -130,6 +123,24 @@
|
|
130
123
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
131
124
|
</PATH_ELEMENT>
|
132
125
|
</PATH>
|
126
|
+
<PATH>
|
127
|
+
<PATH_ELEMENT>
|
128
|
+
<option name="myItemId" value="mongoid_followable" />
|
129
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
130
|
+
</PATH_ELEMENT>
|
131
|
+
<PATH_ELEMENT>
|
132
|
+
<option name="myItemId" value="mongoid_followable" />
|
133
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
134
|
+
</PATH_ELEMENT>
|
135
|
+
<PATH_ELEMENT>
|
136
|
+
<option name="myItemId" value="spec" />
|
137
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
138
|
+
</PATH_ELEMENT>
|
139
|
+
<PATH_ELEMENT>
|
140
|
+
<option name="myItemId" value="mongoid" />
|
141
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
142
|
+
</PATH_ELEMENT>
|
143
|
+
</PATH>
|
133
144
|
<PATH>
|
134
145
|
<PATH_ELEMENT>
|
135
146
|
<option name="myItemId" value="mongoid_followable" />
|
@@ -200,8 +211,8 @@
|
|
200
211
|
</PATH>
|
201
212
|
</subPane>
|
202
213
|
</pane>
|
203
|
-
<pane id="Favorites" />
|
204
214
|
<pane id="Scope" />
|
215
|
+
<pane id="Favorites" />
|
205
216
|
</panes>
|
206
217
|
</component>
|
207
218
|
<component name="RecentsManager">
|
@@ -256,14 +267,14 @@
|
|
256
267
|
<servers />
|
257
268
|
</component>
|
258
269
|
<component name="ToolWindowManager">
|
259
|
-
<frame x="1" y="24" width="
|
270
|
+
<frame x="-1" y="24" width="1282" height="757" extended-state="6" />
|
260
271
|
<editor active="true" />
|
261
272
|
<layout>
|
262
273
|
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
263
274
|
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
264
275
|
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
|
265
276
|
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
266
|
-
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.
|
277
|
+
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.17595541" sideWeight="0.67128986" order="0" side_tool="false" content_ui="tabs" />
|
267
278
|
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
268
279
|
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
269
280
|
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
@@ -324,66 +335,75 @@
|
|
324
335
|
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" />
|
325
336
|
</provider>
|
326
337
|
</entry>
|
327
|
-
<entry file="file://$PROJECT_DIR$/
|
338
|
+
<entry file="file://$PROJECT_DIR$/app/models/follow.rb">
|
328
339
|
<provider selected="true" editor-type-id="text-editor">
|
329
|
-
<state line="
|
340
|
+
<state line="10" column="44" selection-start="315" selection-end="315" vertical-scroll-proportion="0.2173913" />
|
330
341
|
</provider>
|
331
342
|
</entry>
|
332
|
-
<entry file="file://$PROJECT_DIR$/
|
343
|
+
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable.rb">
|
333
344
|
<provider selected="true" editor-type-id="text-editor">
|
334
|
-
<state line="
|
345
|
+
<state line="1" column="70" selection-start="145" selection-end="145" vertical-scroll-proportion="0.0">
|
346
|
+
<folding />
|
347
|
+
</state>
|
335
348
|
</provider>
|
336
349
|
</entry>
|
337
|
-
<entry file="file://$PROJECT_DIR$/
|
350
|
+
<entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
|
338
351
|
<provider selected="true" editor-type-id="text-editor">
|
339
|
-
<state line="
|
352
|
+
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0" />
|
340
353
|
</provider>
|
341
354
|
</entry>
|
342
|
-
<entry file="file://$PROJECT_DIR$/
|
355
|
+
<entry file="file://$PROJECT_DIR$/spec/models/group.rb">
|
343
356
|
<provider selected="true" editor-type-id="text-editor">
|
344
|
-
<state line="
|
357
|
+
<state line="2" column="29" selection-start="69" selection-end="69" vertical-scroll-proportion="0.050167225">
|
345
358
|
<folding />
|
346
359
|
</state>
|
347
360
|
</provider>
|
348
361
|
</entry>
|
349
|
-
<entry file="file://$PROJECT_DIR$/
|
362
|
+
<entry file="file://$PROJECT_DIR$/spec/models/user.rb">
|
350
363
|
<provider selected="true" editor-type-id="text-editor">
|
351
|
-
<state line="
|
364
|
+
<state line="3" column="27" selection-start="96" selection-end="96" vertical-scroll-proportion="0.075250834">
|
352
365
|
<folding />
|
353
366
|
</state>
|
354
367
|
</provider>
|
355
368
|
</entry>
|
356
|
-
<entry file="file://$PROJECT_DIR$/
|
369
|
+
<entry file="file://$PROJECT_DIR$/spec/mongoid/followable_spec.rb">
|
357
370
|
<provider selected="true" editor-type-id="text-editor">
|
358
|
-
<state line="
|
371
|
+
<state line="81" column="39" selection-start="1933" selection-end="1933" vertical-scroll-proportion="0.0">
|
359
372
|
<folding />
|
360
373
|
</state>
|
361
374
|
</provider>
|
362
375
|
</entry>
|
363
376
|
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable/version.rb">
|
364
377
|
<provider selected="true" editor-type-id="text-editor">
|
365
|
-
<state line="2" column="20" selection-start="55" selection-end="55" vertical-scroll-proportion="0.
|
378
|
+
<state line="2" column="20" selection-start="55" selection-end="55" vertical-scroll-proportion="0.0">
|
366
379
|
<folding />
|
367
380
|
</state>
|
368
381
|
</provider>
|
369
382
|
</entry>
|
370
|
-
<entry file="file://$PROJECT_DIR$/
|
383
|
+
<entry file="file://$PROJECT_DIR$/mongoid_followable.gemspec">
|
371
384
|
<provider selected="true" editor-type-id="text-editor">
|
372
|
-
<state line="
|
385
|
+
<state line="8" column="29" selection-start="292" selection-end="292" vertical-scroll-proportion="0.0">
|
373
386
|
<folding />
|
374
387
|
</state>
|
375
388
|
</provider>
|
376
389
|
</entry>
|
377
|
-
<entry file="file://$PROJECT_DIR$/
|
390
|
+
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable/follower.rb">
|
378
391
|
<provider selected="true" editor-type-id="text-editor">
|
379
|
-
<state line="
|
392
|
+
<state line="50" column="47" selection-start="1244" selection-end="1244" vertical-scroll-proportion="0.7948718">
|
380
393
|
<folding />
|
381
394
|
</state>
|
382
395
|
</provider>
|
383
396
|
</entry>
|
384
|
-
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable.rb">
|
397
|
+
<entry file="file://$PROJECT_DIR$/lib/mongoid_followable/followable.rb">
|
398
|
+
<provider selected="true" editor-type-id="text-editor">
|
399
|
+
<state line="50" column="15" selection-start="1230" selection-end="1230" vertical-scroll-proportion="0.9498328">
|
400
|
+
<folding />
|
401
|
+
</state>
|
402
|
+
</provider>
|
403
|
+
</entry>
|
404
|
+
<entry file="file://$PROJECT_DIR$/README.rdoc">
|
385
405
|
<provider selected="true" editor-type-id="text-editor">
|
386
|
-
<state line="
|
406
|
+
<state line="26" column="50" selection-start="693" selection-end="693" vertical-scroll-proportion="0.53846157">
|
387
407
|
<folding />
|
388
408
|
</state>
|
389
409
|
</provider>
|
data/README.rdoc
CHANGED
@@ -5,14 +5,15 @@
|
|
5
5
|
In console:
|
6
6
|
gem install mongoid_followable
|
7
7
|
or in Gemfile:
|
8
|
-
gem 'mongoid_followable', "
|
8
|
+
gem 'mongoid_followable', "~> 0.1.5"
|
9
9
|
|
10
10
|
== Usage
|
11
11
|
|
12
|
-
To make model followable you need to include Mongoid::Followable into your document:
|
12
|
+
To make model followable you need to include Mongoid::Followable into your document;Meanwhile, you also need to include Mongoid::Follower in your follower model:
|
13
13
|
class User
|
14
14
|
include Mongoid::Document
|
15
15
|
include Mongoid::Followable
|
16
|
+
include Mongoid::Follower
|
16
17
|
end
|
17
18
|
|
18
19
|
class Group
|
@@ -20,20 +21,30 @@ To make model followable you need to include Mongoid::Followable into your docum
|
|
20
21
|
include Mongoid::Followable
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
+
You can set authorization:
|
24
25
|
...
|
26
|
+
current_user.set_authorization('user', 'game') # now current_user cannot follow User and Game model
|
27
|
+
current_user.unset_authorization('User', 'Game')
|
28
|
+
|
29
|
+
You can follow a model:
|
30
|
+
|
25
31
|
@group = Group.new
|
26
32
|
@group.save
|
27
33
|
|
28
34
|
current_user.follow(@group)
|
29
|
-
|
30
35
|
current_user.unfollow(@group)
|
36
|
+
|
37
|
+
You can also judge whether a model is a follower of another model or a model is a followee of another model:
|
31
38
|
|
32
39
|
current_user.follower_of?(@group)
|
33
40
|
current_user.followee_of?(@group)
|
34
|
-
|
41
|
+
|
42
|
+
You can get a model's follower/followee count:
|
43
|
+
|
35
44
|
current_user.followers_count
|
36
45
|
current_user.followees_count
|
46
|
+
|
47
|
+
You can get a model's followers/followees:
|
37
48
|
|
38
49
|
User.followers_of(@group)
|
39
50
|
User.followees_of(@group)
|
@@ -41,13 +52,22 @@ Now you can follow others in your controller:
|
|
41
52
|
@group.all_followers
|
42
53
|
@user.all_followees
|
43
54
|
|
55
|
+
You can get a model's followers/followees by type
|
56
|
+
|
44
57
|
@group.followers_by_type("user")
|
45
58
|
@user.followees_by_type("group")
|
46
59
|
|
60
|
+
And their count:
|
61
|
+
|
47
62
|
@group.followers_by_type("user")
|
48
63
|
@group.followers_count_by_type("user")
|
49
64
|
@user.followees_by_type("group")
|
50
65
|
@user.followees_count_by_type("group")
|
66
|
+
|
67
|
+
You can also get a model's follow/followed history:
|
68
|
+
|
69
|
+
@user.ever_follow
|
70
|
+
@group.ever_followed
|
51
71
|
...
|
52
72
|
|
53
73
|
* Any bug or issue, please send me an email: ustc.flyingfox@gmail.com
|
@@ -55,10 +75,11 @@ Now you can follow others in your controller:
|
|
55
75
|
== TODO
|
56
76
|
|
57
77
|
* inter-models followable #FINISHED#
|
58
|
-
* divide into two parts: followable(being followed) and follower(following others)
|
78
|
+
* divide into two parts: followable(being followed) and follower(following others) #FINISHED#
|
59
79
|
* following history/followed history
|
60
80
|
* most/least followed/following
|
61
|
-
*
|
81
|
+
* add authorization to followable models
|
82
|
+
* follow part of model like only following tags updation of an article etc(is this necessary?)
|
62
83
|
|
63
84
|
== Thanks
|
64
85
|
|
@@ -3,6 +3,8 @@ module Mongoid
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do |base|
|
6
|
+
base.field :cannot_followed, :type => Array, :default => []
|
7
|
+
base.field :followed_history, :type => Array, :default => []
|
6
8
|
base.has_many :followers, :class_name => "Follow", :as => :followable, :dependent => :destroy
|
7
9
|
end
|
8
10
|
|
@@ -29,6 +31,26 @@ module Mongoid
|
|
29
31
|
|
30
32
|
end
|
31
33
|
|
34
|
+
# set which models cannot follow self
|
35
|
+
#
|
36
|
+
# Example:
|
37
|
+
# >> @ruby.set_authorization('user')
|
38
|
+
# => true
|
39
|
+
|
40
|
+
def set_authorization(*models)
|
41
|
+
models.each do |model|
|
42
|
+
self.cannot_followed << model.capitalize
|
43
|
+
end
|
44
|
+
self.save
|
45
|
+
end
|
46
|
+
|
47
|
+
def unset_authorization(*models)
|
48
|
+
models.each do |model|
|
49
|
+
self.cannot_followed -= [model.capitalize]
|
50
|
+
end
|
51
|
+
self.save
|
52
|
+
end
|
53
|
+
|
32
54
|
# see if this model is followee of some model
|
33
55
|
#
|
34
56
|
# Example:
|
@@ -79,6 +101,20 @@ module Mongoid
|
|
79
101
|
self.followers.by_type(type).count
|
80
102
|
end
|
81
103
|
|
104
|
+
# see model's followed history
|
105
|
+
#
|
106
|
+
# Example:
|
107
|
+
# >> @ruby.ever_followed
|
108
|
+
# => [@jim]
|
109
|
+
|
110
|
+
def ever_followed
|
111
|
+
follow = []
|
112
|
+
self.followed_history.each do |h|
|
113
|
+
follow << h.split('_')[0].constantize.find(h.split('_')[1])
|
114
|
+
end
|
115
|
+
follow
|
116
|
+
end
|
117
|
+
|
82
118
|
private
|
83
119
|
def rebuild_instances(follows)
|
84
120
|
follow_list = []
|
@@ -3,6 +3,8 @@ module Mongoid
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do |base|
|
6
|
+
base.field :cannot_follow, :type => Array, :default => []
|
7
|
+
base.field :follow_history, :type => Array, :default => []
|
6
8
|
base.has_many :followees, :class_name => "Follow", :as => :following, :dependent => :destroy
|
7
9
|
end
|
8
10
|
|
@@ -29,6 +31,28 @@ module Mongoid
|
|
29
31
|
|
30
32
|
end
|
31
33
|
|
34
|
+
# set which models user cannot follow
|
35
|
+
#
|
36
|
+
# Example:
|
37
|
+
# >> @jim.set_authorization('group', 'user')
|
38
|
+
# => true
|
39
|
+
|
40
|
+
def set_authorization(*models)
|
41
|
+
models.each do |model|
|
42
|
+
self.cannot_follow << model.capitalize
|
43
|
+
end
|
44
|
+
self.save
|
45
|
+
end
|
46
|
+
|
47
|
+
#unset which models user cannot follow
|
48
|
+
|
49
|
+
def unset_authorization(*models)
|
50
|
+
models.each do |model|
|
51
|
+
self.cannot_follow -= [model.capitalize]
|
52
|
+
end
|
53
|
+
self.save
|
54
|
+
end
|
55
|
+
|
32
56
|
# see if this model is follower of some model
|
33
57
|
#
|
34
58
|
# Example:
|
@@ -63,9 +87,13 @@ module Mongoid
|
|
63
87
|
|
64
88
|
def follow(*models)
|
65
89
|
models.each do |model|
|
66
|
-
unless model == self or self.follower_of?(model) or model.followee_of?(self)
|
90
|
+
unless model == self or self.follower_of?(model) or model.followee_of?(self) or self.cannot_follow.include?(model.class.name) or model.cannot_followed.include?(self.class.name)
|
67
91
|
model.followers.create!(:f_type => self.class.name, :f_id => self.id.to_s)
|
92
|
+
model.followed_history << self.class.name + '_' + self.id.to_s
|
93
|
+
model.save
|
68
94
|
self.followees.create!(:f_type => model.class.name, :f_id => model.id.to_s)
|
95
|
+
self.follow_history << model.class.name + '_' + model.id.to_s
|
96
|
+
self.save
|
69
97
|
end
|
70
98
|
end
|
71
99
|
end
|
@@ -74,7 +102,7 @@ module Mongoid
|
|
74
102
|
|
75
103
|
def unfollow(*models)
|
76
104
|
models.each do |model|
|
77
|
-
unless model == self or !self.follower_of?(model) or !model.followee_of?(self)
|
105
|
+
unless model == self or !self.follower_of?(model) or !model.followee_of?(self) or self.cannot_follow.include?(model.class.name) or model.cannot_followed.include?(self.class.name)
|
78
106
|
model.followers.by_model(self).first.destroy
|
79
107
|
self.followees.by_model(model).first.destroy
|
80
108
|
end
|
@@ -101,6 +129,20 @@ module Mongoid
|
|
101
129
|
self.followees.by_type(type).count
|
102
130
|
end
|
103
131
|
|
132
|
+
# see user's follow history
|
133
|
+
#
|
134
|
+
# Example:
|
135
|
+
# >> @jim.ever_follow
|
136
|
+
# => [@ruby]
|
137
|
+
|
138
|
+
def ever_follow
|
139
|
+
follow = []
|
140
|
+
self.follow_history.each do |h|
|
141
|
+
follow << h.split('_')[0].constantize.find(h.split('_')[1])
|
142
|
+
end
|
143
|
+
follow
|
144
|
+
end
|
145
|
+
|
104
146
|
private
|
105
147
|
def rebuild_instances(follows)
|
106
148
|
follow_list = []
|
data/mongoid_followable.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "mongoid_followable"
|
7
7
|
s.version = Mongoid::Followable::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.date = "2011-06-
|
9
|
+
s.date = "2011-06-27"
|
10
10
|
s.authors = ["Jie Fan"]
|
11
11
|
s.email = ["ustc.flyingfox@gmail.com"]
|
12
12
|
s.homepage = "https://github.com/lastomato/mongoid_followable"
|
@@ -35,6 +35,9 @@ describe Mongoid::Followable do
|
|
35
35
|
|
36
36
|
u.followees_count_by_type("user").should == 1
|
37
37
|
@v.followers_count_by_type("user").should == 1
|
38
|
+
|
39
|
+
u.ever_follow.should == [@v]
|
40
|
+
@v.ever_followed.should == [u]
|
38
41
|
end
|
39
42
|
|
40
43
|
it "unfollowing a user" do
|
@@ -73,6 +76,11 @@ describe Mongoid::Followable do
|
|
73
76
|
|
74
77
|
u.followees_count_by_type("group").should == 1
|
75
78
|
@g.followers_count_by_type("user").should == 1
|
79
|
+
|
80
|
+
u.follow(@v)
|
81
|
+
|
82
|
+
u.ever_follow.should == [@g, @v]
|
83
|
+
@g.ever_followed.should == [u]
|
76
84
|
end
|
77
85
|
|
78
86
|
it "unfollowing a group" do
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_followable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
5
|
+
version: 0.1.5
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Jie Fan
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-27 00:00:00 -04:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,11 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ~>
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 1
|
34
24
|
version: 2.0.1
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -42,11 +32,6 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ~>
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 27
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 3
|
49
|
-
- 0
|
50
35
|
version: 1.3.0
|
51
36
|
type: :runtime
|
52
37
|
version_requirements: *id002
|
@@ -58,10 +43,6 @@ dependencies:
|
|
58
43
|
requirements:
|
59
44
|
- - ~>
|
60
45
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 7
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
- 6
|
65
46
|
version: "0.6"
|
66
47
|
type: :development
|
67
48
|
version_requirements: *id003
|
@@ -73,10 +54,6 @@ dependencies:
|
|
73
54
|
requirements:
|
74
55
|
- - ~>
|
75
56
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 15
|
77
|
-
segments:
|
78
|
-
- 2
|
79
|
-
- 6
|
80
57
|
version: "2.6"
|
81
58
|
type: :development
|
82
59
|
version_requirements: *id004
|
@@ -128,23 +105,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
105
|
requirements:
|
129
106
|
- - ">="
|
130
107
|
- !ruby/object:Gem::Version
|
131
|
-
hash: 3
|
132
|
-
segments:
|
133
|
-
- 0
|
134
108
|
version: "0"
|
135
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
110
|
none: false
|
137
111
|
requirements:
|
138
112
|
- - ">="
|
139
113
|
- !ruby/object:Gem::Version
|
140
|
-
hash: 3
|
141
|
-
segments:
|
142
|
-
- 0
|
143
114
|
version: "0"
|
144
115
|
requirements: []
|
145
116
|
|
146
117
|
rubyforge_project: mongoid_followable
|
147
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 1.6.2
|
148
119
|
signing_key:
|
149
120
|
specification_version: 3
|
150
121
|
summary: adds following feature to models
|