Module: DataMapper::Model::Hook::Methods

Defined in:
lib/dm-core/model/hook.rb

Instance Method Summary collapse

Instance Method Details

#after(target_method, method_sym = nil, &block) ⇒ Object



25
26
27
# File 'lib/dm-core/model/hook.rb', line 25

def after(target_method, method_sym = nil, &block)
  setup_hook(:after, target_method, method_sym, block) { super }
end

#before(target_method, method_sym = nil, &block) ⇒ Object



20
21
22
# File 'lib/dm-core/model/hook.rb', line 20

def before(target_method, method_sym = nil, &block)
  setup_hook(:before, target_method, method_sym, block) { super }
end

#hooksObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
36
37
# File 'lib/dm-core/model/hook.rb', line 30

def hooks
  @hooks ||= {
    :save     => { :before => [], :after => [] },
    :create   => { :before => [], :after => [] },
    :update   => { :before => [], :after => [] },
    :destroy  => { :before => [], :after => [] },
  }
end

#inherited(model) ⇒ Object



14
15
16
17
# File 'lib/dm-core/model/hook.rb', line 14

def inherited(model)
  copy_hooks(model)
  super
end