Class: SlackRubyBot::Hooks::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/slack-ruby-bot/hooks/set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = nil) ⇒ Set

Returns a new instance of Set.



6
7
8
9
10
11
# File 'lib/slack-ruby-bot/hooks/set.rb', line 6

def initialize(client = nil)
  self.handlers = {}
  self.client = client

  @pending_flush = client.blank?
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/slack-ruby-bot/hooks/set.rb', line 4

def client
  @client
end

#handlersObject

Returns the value of attribute handlers.



4
5
6
# File 'lib/slack-ruby-bot/hooks/set.rb', line 4

def handlers
  @handlers
end

Instance Method Details

#add(hook_name, handler) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/slack-ruby-bot/hooks/set.rb', line 13

def add(hook_name, handler)
  if handlers[hook_name].present?
    handlers[hook_name] << handler
  else
    handlers[hook_name] = [handler]
    register_callback(hook_name)
  end
end