Class: Apia::HookSet

Inherits:
Object
  • Object
show all
Defined in:
lib/apia/hook_set.rb

Instance Method Summary collapse

Constructor Details

#initializeHookSet

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/apia/hook_set.rb', line 21

def include?(proc)
  @hooks.include?(proc)
end

#sizeObject



25
26
27
# File 'lib/apia/hook_set.rb', line 25

def size
  @hooks.size
end