module Socialization::Follower

Public Instance Methods

follow!(followable) click to toggle source

Create a new {Follow follow} relationship.

@param [Followable] followable the object to be followed. @return [Boolean]

# File lib/socialization/actors/follower.rb, line 29
def follow!(followable)
  raise Socialization::ArgumentError, "#{followable} is not followable!"  unless followable.respond_to?(:is_followable?) && followable.is_followable?
  Socialization.follow_model.follow!(self, followable)
end
followables(klass, opts = {}) click to toggle source

Returns all the followables of a certain type that are followed by self

@params [Followable] klass the type of {Followable} you want @params [Hash] opts a hash of options @return [Array<Followable, Numeric>] An array of Followable objects or IDs

# File lib/socialization/actors/follower.rb, line 72
def followables(klass, opts = {})
  Socialization.follow_model.followables(self, klass, opts)
end
Also aliased as: followees
followables_relation(klass, opts = {}) click to toggle source

Returns a relation for all the followables of a certain type that are followed by self

@params [Followable] klass the type of {Followable} you want @params [Hash] opts a hash of options @return ActiveRecord::Relation

# File lib/socialization/actors/follower.rb, line 82
def followables_relation(klass, opts = {})
  Socialization.follow_model.followables_relation(self, klass, opts)
end
Also aliased as: followees_relation
followees(klass, opts = {})
Alias for: followables
followees_relation(klass, opts = {})
follower?()
Alias for: is_follower?
follows?(followable) click to toggle source

Specifies if self follows a {Followable} object.

@param [Followable] followable the {Followable} object to test against. @return [Boolean]

# File lib/socialization/actors/follower.rb, line 62
def follows?(followable)
  raise Socialization::ArgumentError, "#{followable} is not followable!" unless followable.respond_to?(:is_followable?) && followable.is_followable?
  Socialization.follow_model.follows?(self, followable)
end
is_follower?() click to toggle source

Specifies if self can follow {Followable} objects.

@return [Boolean]

# File lib/socialization/actors/follower.rb, line 20
def is_follower?
  true
end
Also aliased as: follower?
toggle_follow!(followable) click to toggle source

Toggles a {Follow follow} relationship.

@param [Followable] followable the object to follow/unfollow. @return [Boolean]

# File lib/socialization/actors/follower.rb, line 47
def toggle_follow!(followable)
  raise Socialization::ArgumentError, "#{followable} is not followable!" unless followable.respond_to?(:is_followable?) && followable.is_followable?
  if follows?(followable)
    unfollow!(followable)
    false
  else
    follow!(followable)
    true
  end
end
unfollow!(followable) click to toggle source

Delete a {Follow follow} relationship.

@param [Followable] followable the object to unfollow. @return [Boolean]

# File lib/socialization/actors/follower.rb, line 38
def unfollow!(followable)
  raise Socialization::ArgumentError, "#{followable} is not followable!" unless followable.respond_to?(:is_followable?) && followable.is_followable?
  Socialization.follow_model.unfollow!(self, followable)
end