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.



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

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

  @pending_flush = client.blank?
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#handlersObject

Returns the value of attribute handlers.



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

def handlers
  @handlers
end

Instance Method Details

#add(hook_name, handler) ⇒ Object



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

def add(hook_name, handler)
  handlers[hook_name] ||= ::Set.new
  handlers[hook_name] << handler

  register_callback(hook_name)
end