module Socialization::Mentionable

Public Instance Methods

is_mentionable?() click to toggle source

Specifies if self can be mentioned.

@return [Boolean]

# File lib/socialization/subjects/mentionable.rb, line 20
def is_mentionable?
  true
end
Also aliased as: mentionable?
mentionable?()
Alias for: is_mentionable?
mentioned_by?(mentioner) click to toggle source

Specifies if self is mentioned by a {Mentioner} object.

@return [Boolean]

# File lib/socialization/subjects/mentionable.rb, line 28
def mentioned_by?(mentioner)
  raise Socialization::ArgumentError, "#{mentioner} is not mentioner!"  unless mentioner.respond_to?(:is_mentioner?) && mentioner.is_mentioner?
  Socialization.mention_model.mentions?(mentioner, self)
end
mentioners(klass, opts = {}) click to toggle source

Returns an array of {Mentioner}s mentioning self.

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

# File lib/socialization/subjects/mentionable.rb, line 37
def mentioners(klass, opts = {})
  Socialization.mention_model.mentioners(self, klass, opts)
end
mentioners_relation(klass, opts = {}) click to toggle source

Returns a scope of the {Mentioner}s mentioning self.

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

# File lib/socialization/subjects/mentionable.rb, line 45
def mentioners_relation(klass, opts = {})
  Socialization.mention_model.mentioners_relation(self, klass, opts)
end