Class: HookR::HookSet
- Inherits:
-
Set
- Object
- Set
- HookR::HookSet
- Defined in:
- lib/hookr.rb
Constant Summary collapse
Instance Method Summary collapse
-
#[](key) ⇒ Object
Find hook by name.
- #deep_copy ⇒ Object
-
#length ⇒ Object
Length minus the wildcard hook (if any).
Instance Method Details
#[](key) ⇒ Object
Find hook by name.
TODO: Optimize this.
463 464 465 |
# File 'lib/hookr.rb', line 463 def [](key) detect {|v| v.name == key} or raise IndexError, "No such hook: #{key}" end |
#deep_copy ⇒ Object
467 468 469 470 471 472 473 |
# File 'lib/hookr.rb', line 467 def deep_copy result = HookSet.new each do |hook| result << hook.dup end result end |
#length ⇒ Object
Length minus the wildcard hook (if any)
476 477 478 479 480 481 482 |
# File 'lib/hookr.rb', line 476 def length if include?(WILDCARD_HOOK) super - 1 else super end end |