module Socialization::Likeable

Public Instance Methods

is_likeable?() click to toggle source

Specifies if self can be liked.

@return [Boolean]

# File lib/socialization/subjects/likeable.rb, line 20
def is_likeable?
  true
end
Also aliased as: likeable?
likeable?()
Alias for: is_likeable?
liked_by?(liker) click to toggle source

Specifies if self is liked by a {Liker} object.

@return [Boolean]

# File lib/socialization/subjects/likeable.rb, line 28
def liked_by?(liker)
  raise Socialization::ArgumentError, "#{liker} is not liker!"  unless liker.respond_to?(:is_liker?) && liker.is_liker?
  Socialization.like_model.likes?(liker, self)
end
likers(klass, opts = {}) click to toggle source

Returns an array of {Liker}s liking self.

@param [Class] klass the {Liker} class to be included. e.g. `User` @return [Array<Liker, Numeric>] An array of Liker objects or IDs

# File lib/socialization/subjects/likeable.rb, line 37
def likers(klass, opts = {})
  Socialization.like_model.likers(self, klass, opts)
end
likers_relation(klass, opts = {}) click to toggle source

Returns a scope of the {Liker}s liking self.

@param [Class] klass the {Liker} class to be included in the scope. e.g. `User` @return ActiveRecord::Relation

# File lib/socialization/subjects/likeable.rb, line 45
def likers_relation(klass, opts = {})
  Socialization.like_model.likers_relation(self, klass, opts)
end