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


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

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


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

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.


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

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

#inherited(model) ⇒ Object


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

def inherited(model)
  copy_hooks(model)
  super
end