Commit 098a29803df20a1b60f1838d6d9a29466bf6f281

Authored by Amol Udage
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 module ActsAsFollower #:nodoc: 1 module ActsAsFollower #:nodoc:
2 module FollowScopes 2 module FollowScopes
3 3
  4 + # returns Follow records where follower is the record passed in.
4 def for_follower(follower) 5 def for_follower(follower)
5 where(:follower_id => follower.id, 6 where(:follower_id => follower.id,
6 :follower_type => parent_class_name(follower)) 7 :follower_type => parent_class_name(follower))
7 end 8 end
8 9
  10 + # returns Follow records where followable is the record passed in.
9 def for_followable(followable) 11 def for_followable(followable)
10 where(:followable_id => followable.id, :followable_type => parent_class_name(followable)) 12 where(:followable_id => followable.id, :followable_type => parent_class_name(followable))
11 end 13 end
12 14
  15 + # returns Follow records where follower_type is the record passed in.
13 def for_follower_type(follower_type) 16 def for_follower_type(follower_type)
14 where(:follower_type => follower_type) 17 where(:follower_type => follower_type)
15 end 18 end
16 19
  20 + # returns Follow records where followeable_type is the record passed in.
17 def for_followable_type(followable_type) 21 def for_followable_type(followable_type)
18 where(:followable_type => followable_type) 22 where(:followable_type => followable_type)
19 end 23 end
20 24
  25 + # returns Follow records from past 2 weeks with default parameter.
21 def recent(from) 26 def recent(from)
22 where(["created_at > ?", (from || 2.weeks.ago).to_s(:db)]) 27 where(["created_at > ?", (from || 2.weeks.ago).to_s(:db)])
23 end 28 end
24 29
  30 + # returns Follow records in descending order.
25 def descending 31 def descending
26 order("follows.created_at DESC") 32 order("follows.created_at DESC")
27 end 33 end
28 34
  35 + # returns unblocked Follow records.
29 def unblocked 36 def unblocked
30 where(:blocked => false) 37 where(:blocked => false)
31 end 38 end
32 39
  40 + # returns blocked Follow records.
33 def blocked 41 def blocked
34 where(:blocked => true) 42 where(:blocked => true)
35 end 43 end