Class: Apia::HookSet
- Inherits:
-
Object
- Object
- Apia::HookSet
- Defined in:
- lib/apia/hook_set.rb
Instance Method Summary collapse
- #add(block_by_var = nil, &block) ⇒ Object
- #call(*args) ⇒ Object
- #include?(proc) ⇒ Boolean
-
#initialize ⇒ HookSet
constructor
A new instance of HookSet.
- #size ⇒ Object
Constructor Details
#initialize ⇒ HookSet
Returns a new instance of HookSet.
6 7 8 |
# File 'lib/apia/hook_set.rb', line 6 def initialize @hooks = [] end |
Instance Method Details
#add(block_by_var = nil, &block) ⇒ Object
10 11 12 13 |
# File 'lib/apia/hook_set.rb', line 10 def add(block_by_var = nil, &block) @hooks << block_by_var if block_by_var.is_a?(Proc) @hooks << block if block_given? end |
#call(*args) ⇒ Object
15 16 17 18 19 |
# File 'lib/apia/hook_set.rb', line 15 def call(*args) @hooks.map do |hook| hook.call(*args) end end |
#include?(proc) ⇒ Boolean
21 22 23 |
# File 'lib/apia/hook_set.rb', line 21 def include?(proc) @hooks.include?(proc) end |
#size ⇒ Object
25 26 27 |
# File 'lib/apia/hook_set.rb', line 25 def size @hooks.size end |