Module: Spinach::Hookable::ClassMethods

Defined in:
lib/spinach/hookable.rb

Instance Method Summary collapse

Instance Method Details

#hook(hook) ⇒ Object

Adds a new hook to this class. Every hook defines two methods used to add new callbacks and to run them passing a bunch of parameters.

Examples:

class


23
24
25
26
27
28
29
30
# File 'lib/spinach/hookable.rb', line 23

def hook(hook)
  define_method hook do |&block|
    add_hook(hook, &block)
  end
  define_method "run_#{hook}" do |*args|
    run_hook(hook, *args)
  end
end