module Socialization::Mentioner

Public Instance Methods

is_mentioner?() click to toggle source

Specifies if self can mention {Mentionable} objects.

@return [Boolean]

# File lib/socialization/actors/mentioner.rb, line 20
def is_mentioner?
  true
end
Also aliased as: mentioner?
mention!(mentionable) click to toggle source

Create a new {Mention mention} relationship.

@param [Mentionable] mentionable the object to be mentioned. @return [Boolean]

# File lib/socialization/actors/mentioner.rb, line 29
def mention!(mentionable)
  raise Socialization::ArgumentError, "#{mentionable} is not mentionable!"  unless mentionable.respond_to?(:is_mentionable?) && mentionable.is_mentionable?
  Socialization.mention_model.mention!(self, mentionable)
end
mentionables(klass, opts = {}) click to toggle source

Returns all the mentionables of a certain type that are mentioned by self

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

# File lib/socialization/actors/mentioner.rb, line 72
def mentionables(klass, opts = {})
  Socialization.mention_model.mentionables(self, klass, opts)
end
Also aliased as: mentionees
mentionables_relation(klass, opts = {}) click to toggle source

Returns a relation for all the mentionables of a certain type that are mentioned by self

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

# File lib/socialization/actors/mentioner.rb, line 82
def mentionables_relation(klass, opts = {})
  Socialization.mention_model.mentionables_relation(self, klass, opts)
end
Also aliased as: mentionees_relation
mentionees(klass, opts = {})
Alias for: mentionables
mentionees_relation(klass, opts = {})
mentioner?()
Alias for: is_mentioner?
mentions?(mentionable) click to toggle source

Specifies if self mentions a {Mentionable} object.

@param [Mentionable] mentionable the {Mentionable} object to test against. @return [Boolean]

# File lib/socialization/actors/mentioner.rb, line 62
def mentions?(mentionable)
  raise Socialization::ArgumentError, "#{mentionable} is not mentionable!" unless mentionable.respond_to?(:is_mentionable?) && mentionable.is_mentionable?
  Socialization.mention_model.mentions?(self, mentionable)
end
toggle_mention!(mentionable) click to toggle source

Toggles a {Mention mention} relationship.

@param [Mentionable] mentionable the object to mention/unmention. @return [Boolean]

# File lib/socialization/actors/mentioner.rb, line 47
def toggle_mention!(mentionable)
  raise Socialization::ArgumentError, "#{mentionable} is not mentionable!" unless mentionable.respond_to?(:is_mentionable?) && mentionable.is_mentionable?
  if mentions?(mentionable)
    unmention!(mentionable)
    false
  else
    mention!(mentionable)
    true
  end
end
unmention!(mentionable) click to toggle source

Delete a {Mention mention} relationship.

@param [Mentionable] mentionable the object to unmention. @return [Boolean]

# File lib/socialization/actors/mentioner.rb, line 38
def unmention!(mentionable)
  raise Socialization::ArgumentError, "#{mentionable} is not mentionable!" unless mentionable.respond_to?(:is_mentionable?) && mentionable.is_mentionable?
  Socialization.mention_model.unmention!(self, mentionable)
end