Class Hooks::Hook
In: lib/hooks/hook.rb
Parent: Array

Methods

<<   new   run  

Classes and Modules

Class Hooks::Hook::Results

Public Class methods

Public Instance methods

The chain contains the return values of the executed callbacks.

Example:

  class Person
    define_hook :before_eating

    before_eating :wash_hands
    before_eating :locate_food
    before_eating :sit_down

    def wash_hands; :washed_hands; end
    def locate_food; :located_food; false; end
    def sit_down; :sat_down; end
  end

  result = person.run_hook(:before_eating)
  result.chain #=> [:washed_hands, false, :sat_down]

If :halts_on_falsey is enabled:

  class Person
    define_hook :before_eating, :halts_on_falsey => true
    # ...
  end

  result = person.run_hook(:before_eating)
  result.chain #=> [:washed_hands]

[Validate]