Module: FollowableBehaviour::FollowScopes
- Included in:
- Follow
- Defined in:
- lib/followable_behaviour/follow_scopes.rb
Instance Method Summary collapse
-
#blocked ⇒ Object
returns blocked Follow records.
-
#descending ⇒ Object
returns Follow records in descending order.
-
#for_followable(followable) ⇒ Object
returns Follow records where followable is the record passed in.
-
#for_followable_type(followable_type) ⇒ Object
returns Follow records where followeable_type is the record passed in.
-
#for_follower(follower) ⇒ Object
returns Follow records where follower is the record passed in.
-
#for_follower_type(follower_type) ⇒ Object
returns Follow records where follower_type is the record passed in.
-
#recent(from) ⇒ Object
returns Follow records from past 2 weeks with default parameter.
-
#unblocked ⇒ Object
returns unblocked Follow records.
Instance Method Details
#blocked ⇒ Object
returns blocked Follow records.
40 41 42 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 40 def blocked where(blocked: true) end |
#descending ⇒ Object
returns Follow records in descending order.
30 31 32 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 30 def descending order("follows.created_at DESC") end |
#for_followable(followable) ⇒ Object
returns Follow records where followable is the record passed in.
10 11 12 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 10 def for_followable(followable) where(followable_id: followable.id, followable_type: parent_class_name(followable)) end |
#for_followable_type(followable_type) ⇒ Object
returns Follow records where followeable_type is the record passed in.
20 21 22 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 20 def for_followable_type(followable_type) where(followable_type: followable_type) end |
#for_follower(follower) ⇒ Object
returns Follow records where follower is the record passed in.
5 6 7 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 5 def for_follower(follower) where(follower_id: follower.id, follower_type: parent_class_name(follower)) end |
#for_follower_type(follower_type) ⇒ Object
returns Follow records where follower_type is the record passed in.
15 16 17 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 15 def for_follower_type(follower_type) where(follower_type: follower_type) end |
#recent(from) ⇒ Object
returns Follow records from past 2 weeks with default parameter.
25 26 27 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 25 def recent(from) where(["created_at > ?", (from || 2.weeks.ago).to_s(:db)]) end |
#unblocked ⇒ Object
returns unblocked Follow records.
35 36 37 |
# File 'lib/followable_behaviour/follow_scopes.rb', line 35 def unblocked where(blocked: false) end |