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.
485 486 487 |
# File 'lib/hookr.rb', line 485 def [](key) detect {|v| v.name == key} or raise IndexError, "No such hook: #{key}" end |
#deep_copy ⇒ Object
489 490 491 492 493 494 495 |
# File 'lib/hookr.rb', line 489 def deep_copy result = HookSet.new each do |hook| result << hook.dup end result end |
#length ⇒ Object
Length minus the wildcard hook (if any)
498 499 500 501 502 503 504 |
# File 'lib/hookr.rb', line 498 def length if include?(WILDCARD_HOOK) super - 1 else super end end |