Module: Mentionable::ClassMethods

Defined in:
lib/mentionable.rb

Instance Method Summary collapse

Instance Method Details

#mentionable_as(column, on_mention: :after_save_mention, hook_name: :after_save, regexp: REGEXP) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/mentionable.rb', line 13

def mentionable_as(column, on_mention: :after_save_mention, hook_name: :after_save, regexp: REGEXP)
  class_variable_set :@@mentionable_name, column
  class_variable_set :@@on_mention, on_mention
  class_variable_set :@@hook_name, hook_name
  class_variable_set :@@regexp, regexp

  public_send hook_name do
    public_send on_mention, new_mentions if new_mentions?
  end
end

#mentionable_nameObject



24
25
26
# File 'lib/mentionable.rb', line 24

def mentionable_name
  class_variable_get :@@mentionable_name
end

#on_mentionObject



28
29
30
# File 'lib/mentionable.rb', line 28

def on_mention
  class_variable_get :@@on_mention
end

#regexpObject



32
33
34
# File 'lib/mentionable.rb', line 32

def regexp
  class_variable_get :@@regexp
end