Class: HookR::CallbackSet
- Inherits:
-
SortedSet
- Object
- SortedSet
- HookR::CallbackSet
- Defined in:
- lib/hookr.rb
Instance Method Summary collapse
-
#[](index) ⇒ Object
Fetch callback by either index or handle.
- #each_reverse(&block) ⇒ Object
-
#first ⇒ Object
get the first callback.
Instance Method Details
#[](index) ⇒ Object
Fetch callback by either index or handle
503 504 505 506 507 508 509 |
# File 'lib/hookr.rb', line 503 def [](index) case index when Integer then detect{|cb| cb.index == index} when Symbol then detect{|cb| cb.handle == index} else raise ArgumentError, "index must be Integer or Symbol" end end |
#each_reverse(&block) ⇒ Object
518 519 520 |
# File 'lib/hookr.rb', line 518 def each_reverse(&block) sort{|x, y| y <=> x}.each(&block) end |
#first ⇒ Object
get the first callback
512 513 514 515 516 |
# File 'lib/hookr.rb', line 512 def first each do |cb| return cb end end |