Module: WingedCouch::Models::Hooks::ClassMethods

Defined in:
lib/winged_couch/models/hooks.rb

Instance Method Summary collapse

Instance Method Details

#after(hook_action, method_name = nil, &block) ⇒ Object

Defines after hooks

Parameters:

  • hook_action (Symbol)

    can be :save, :update, :delete, :initialize

  • method_name (Symbol) (defaults to: nil)

    name of the method to be called, optional

  • block (Proc)

    black to be executed, optional


29
30
31
# File 'lib/winged_couch/models/hooks.rb', line 29

def after(hook_action, method_name = nil, &block)
  hooks[:after][hook_action] << (method_name || block)
end

#before(hook_action, method_name = nil, &block) ⇒ Object

Defines before hooks

Parameters:

  • hook_action (Symbol)

    can be :save, :update, :delete

  • method_name (Symbol) (defaults to: nil)

    name of the method to be called, optional

  • block (Proc)

    black to be executed, optional


19
20
21
# File 'lib/winged_couch/models/hooks.rb', line 19

def before(hook_action, method_name = nil, &block)
  hooks[:before][hook_action] << (method_name || block)
end