Commit 098a29803df20a1b60f1838d6d9a29466bf6f281
1 parent
a04dfa05
Exists in
master
Add short description for ActsAsFollower::FollowScopes methods
Showing
1 changed file
with
8 additions
and
0 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 | ... | ... |