Module: FollowSystem::Follower

Extended by:
ActiveSupport::Concern
Defined in:
lib/follow_system/follower.rb

Overview

Follower module

This module defines follower behavior in follow system

Instance Method Summary collapse

Instance Method Details

#follow(followee) ⇒ Boolean

Creates a FollowSystem::Follow relationship between self and a FollowSystem::Followee object

Parameters:

Returns:

  • (Boolean)


43
44
45
# File 'lib/follow_system/follower.rb', line 43

def follow(followee)
  Follow.follow(self, followee)
end

#followees_by(klass) ⇒ ActiveRecord::Relation

Retrieves a scope of FollowSystem::Follow objects that are followed by self

Parameters:

  • klass (Class)
    • the Class to include

Returns:

  • (ActiveRecord::Relation)


83
84
85
# File 'lib/follow_system/follower.rb', line 83

def followees_by(klass)
  Follow.scope_by_follower(self).scope_by_followee_type(klass)
end

#follows?(followee) ⇒ Boolean

Specifies if self follows a FollowSystem::Follower object

Parameters:

Returns:

  • (Boolean)


73
74
75
# File 'lib/follow_system/follower.rb', line 73

def follows?(followee)
  Follow.follows?(self, followee)
end

#is_follower?Boolean

Specifies if self can follow FollowSystem::Followee objects

Returns:

  • (Boolean)


33
34
35
# File 'lib/follow_system/follower.rb', line 33

def is_follower?
  true
end

#toggle_follow(followee) ⇒ Boolean

Toggles a FollowSystem::Follow relationship between self and a FollowSystem::Followee object

Parameters:

Returns:

  • (Boolean)


63
64
65
# File 'lib/follow_system/follower.rb', line 63

def toggle_follow(followee)
  Follow.toggle_follow(self, followee)
end

#unfollow(followee) ⇒ Boolean

Destroys a FollowSystem::Follow relationship between self and a FollowSystem::Followee object

Parameters:

Returns:

  • (Boolean)


53
54
55
# File 'lib/follow_system/follower.rb', line 53

def unfollow(followee)
  Follow.unfollow(self, followee)
end