Module: MentionSystem::Mentioner

Extended by:
ActiveSupport::Concern
Defined in:
lib/mention_system/mentioner.rb

Overview

Mentioner module

This module defines mentioner behavior in mention system

Instance Method Summary collapse

Instance Method Details

#is_mentioner?Boolean

Specifies if self can mention MentionSystem::Mentionee objects

Returns:

  • (Boolean)


33
34
35
# File 'lib/mention_system/mentioner.rb', line 33

def is_mentioner?
  true
end

#mention(mentionee) ⇒ Boolean

Creates a MentionSystem::Mention relationship between self and a MentionSystem::Mentionee object

Parameters:

Returns:

  • (Boolean)


43
44
45
# File 'lib/mention_system/mentioner.rb', line 43

def mention(mentionee)
  Mention.mention(self, mentionee)
end

#mentionees_by(klass) ⇒ ActiveRecord::Relation

Retrieves a scope of MentionSystem::Mention objects that are mentioned by self

Parameters:

  • klass (Class)
    • the Class to include

Returns:

  • (ActiveRecord::Relation)


83
84
85
# File 'lib/mention_system/mentioner.rb', line 83

def mentionees_by(klass)
  Mention.scope_by_mentioner(self).scope_by_mentionee_type(klass)
end

#mentions?(mentionee) ⇒ Boolean

Specifies if self mentions a MentionSystem::Mentioner object

Parameters:

Returns:

  • (Boolean)


73
74
75
# File 'lib/mention_system/mentioner.rb', line 73

def mentions?(mentionee)
  Mention.mentions?(self, mentionee)
end

#toggle_mention(mentionee) ⇒ Boolean

Toggles a MentionSystem::Mention relationship between self and a MentionSystem::Mentionee object

Parameters:

Returns:

  • (Boolean)


63
64
65
# File 'lib/mention_system/mentioner.rb', line 63

def toggle_mention(mentionee)
  Mention.toggle_mention(self, mentionee)
end

#unmention(mentionee) ⇒ Boolean

Destroys a MentionSystem::Mention relationship between self and a MentionSystem::Mentionee object

Parameters:

Returns:

  • (Boolean)


53
54
55
# File 'lib/mention_system/mentioner.rb', line 53

def unmention(mentionee)
  Mention.unmention(self, mentionee)
end