Module: SlackRubyBot::Hooks::HookSupport
- Included in:
- Server
- Defined in:
- lib/slack-ruby-bot/hooks/hook_support.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#add_hook_handlers(handler_hash) ⇒ Object
TODO: This should be deprecated in favor of ‘on`.
- #flush_hook_blocks ⇒ Object
-
#hooks ⇒ Object
Instance stuff.
- #on(event_name, handler) ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 |
# File 'lib/slack-ruby-bot/hooks/hook_support.rb', line 6 def self.included(base) base.cattr_accessor :hook_blocks base.extend(ClassMethods) end |
Instance Method Details
#add_hook_handlers(handler_hash) ⇒ Object
TODO: This should be deprecated in favor of ‘on`
38 39 40 41 42 |
# File 'lib/slack-ruby-bot/hooks/hook_support.rb', line 38 def add_hook_handlers(handler_hash) handler_hash.each do |hook, handlers| Array(handlers).each { |handler| on(hook, handler) } end end |
#flush_hook_blocks ⇒ Object
31 32 33 34 35 |
# File 'lib/slack-ruby-bot/hooks/hook_support.rb', line 31 def flush_hook_blocks return nil unless self.class.hook_blocks add_hook_handlers(self.class.hook_blocks) end |
#hooks ⇒ Object
Instance stuff
22 23 24 25 |
# File 'lib/slack-ruby-bot/hooks/hook_support.rb', line 22 def hooks warn Kernel.caller.first + ' [DEPRECATION] `hooks` method is deprecated. Please use `server.on` instead to register a hook.' _hooks end |
#on(event_name, handler) ⇒ Object
27 28 29 |
# File 'lib/slack-ruby-bot/hooks/hook_support.rb', line 27 def on(event_name, handler) _hooks.add(event_name, handler) end |