Class: Unbound::CallbackArray
- Inherits:
-
Array
- Object
- Array
- Unbound::CallbackArray
- Defined in:
- lib/unbound/callback_array.rb
Instance Method Summary collapse
-
#add_callback(*cbs) { ... } ⇒ Object
Registers one or more callbacks.
-
#call(*args) ⇒ Object
Calls each registered callback with the provided arguments.
Instance Method Details
#add_callback(*cbs) { ... } ⇒ Object
Registers one or more callbacks
7 8 9 10 11 |
# File 'lib/unbound/callback_array.rb', line 7 def add_callback(*cbs, &cb_block) cbs.push(cb_block) unless cb_block.nil? raise(ArgumentError.new("Missing callback")) if cbs.empty? concat(cbs) end |
#call(*args) ⇒ Object
Calls each registered callback with the provided arguments
15 16 17 18 19 |
# File 'lib/unbound/callback_array.rb', line 15 def call(*args) each do |cb| cb.call(*args) end end |