Commit c3e00f211dcdd62e8036a354f73377e12d8b4ccc
Committed by
GitHub
Exists in
master
Merge pull request #66 from joshsoftware/method_short_description
Add short description for ActsAsFollower::FollowScopes methods
Showing
3 changed files
with
12 additions
and
4 deletions
Show diff stats
lib/acts_as_follower/follow_scopes.rb
1 | 1 | module ActsAsFollower #:nodoc: |
2 | 2 | module FollowScopes |
3 | 3 | |
4 | + # returns Follow records where follower is the record passed in. | |
4 | 5 | def for_follower(follower) |
5 | 6 | where(:follower_id => follower.id, |
6 | 7 | :follower_type => parent_class_name(follower)) |
7 | 8 | end |
8 | 9 | |
10 | + # returns Follow records where followable is the record passed in. | |
9 | 11 | def for_followable(followable) |
10 | 12 | where(:followable_id => followable.id, :followable_type => parent_class_name(followable)) |
11 | 13 | end |
12 | 14 | |
15 | + # returns Follow records where follower_type is the record passed in. | |
13 | 16 | def for_follower_type(follower_type) |
14 | 17 | where(:follower_type => follower_type) |
15 | 18 | end |
16 | 19 | |
20 | + # returns Follow records where followeable_type is the record passed in. | |
17 | 21 | def for_followable_type(followable_type) |
18 | 22 | where(:followable_type => followable_type) |
19 | 23 | end |
20 | 24 | |
25 | + # returns Follow records from past 2 weeks with default parameter. | |
21 | 26 | def recent(from) |
22 | 27 | where(["created_at > ?", (from || 2.weeks.ago).to_s(:db)]) |
23 | 28 | end |
24 | 29 | |
30 | + # returns Follow records in descending order. | |
25 | 31 | def descending |
26 | 32 | order("follows.created_at DESC") |
27 | 33 | end |
28 | 34 | |
35 | + # returns unblocked Follow records. | |
29 | 36 | def unblocked |
30 | 37 | where(:blocked => false) |
31 | 38 | end |
32 | 39 | |
40 | + # returns blocked Follow records. | |
33 | 41 | def blocked |
34 | 42 | where(:blocked => true) |
35 | 43 | end | ... | ... |
lib/generators/templates/model.rb
... | ... | @@ -3,7 +3,7 @@ class Follow < ActiveRecord::Base |
3 | 3 | extend ActsAsFollower::FollowerLib |
4 | 4 | extend ActsAsFollower::FollowScopes |
5 | 5 | |
6 | - # NOTE: Follows belong to the "followable" interface, and also to followers | |
6 | + # NOTE: Follows belong to the "followable" and "follower" interface | |
7 | 7 | belongs_to :followable, :polymorphic => true |
8 | 8 | belongs_to :follower, :polymorphic => true |
9 | 9 | ... | ... |
test/acts_as_followable_test.rb
... | ... | @@ -189,7 +189,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase |
189 | 189 | assert_equal [], @jon.followers |
190 | 190 | end |
191 | 191 | |
192 | - should "not be in the blockked followers count" do | |
192 | + should "not be in the blocked followers count" do | |
193 | 193 | assert_equal 0, @jon.blocked_followers_count |
194 | 194 | end |
195 | 195 | |
... | ... | @@ -206,7 +206,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase |
206 | 206 | |
207 | 207 | should "return the followers for given type" do |
208 | 208 | assert_equal [@sam], @jon.followers_by_type('User') |
209 | - assert_equal [@sam,@jon], @oasis.followers_by_type('User') | |
209 | + assert_equal [@sam, @jon], @oasis.followers_by_type('User') | |
210 | 210 | end |
211 | 211 | |
212 | 212 | should "not return block followers in the followers for a given type" do |
... | ... | @@ -233,7 +233,7 @@ class ActsAsFollowableTest < ActiveSupport::TestCase |
233 | 233 | |
234 | 234 | should "return the followers for given type" do |
235 | 235 | assert_equal [@sam], @jon.user_followers |
236 | - assert_equal [@sam,@jon], @oasis.user_followers | |
236 | + assert_equal [@sam, @jon], @oasis.user_followers | |
237 | 237 | end |
238 | 238 | |
239 | 239 | should "not return block followers in the followers for a given type" do | ... | ... |