@api public
# File lib/dm-core/model/hook.rb, line 25 25: def after(target_method, method_sym = nil, &block) 26: setup_hook(:after, target_method, method_sym, block) { super } 27: end
@api public
# File lib/dm-core/model/hook.rb, line 20 20: def before(target_method, method_sym = nil, &block) 21: setup_hook(:before, target_method, method_sym, block) { super } 22: end
@api private
# File lib/dm-core/model/hook.rb, line 30 30: def hooks 31: @hooks ||= { 32: :save => { :before => [], :after => [] }, 33: :create => { :before => [], :after => [] }, 34: :update => { :before => [], :after => [] }, 35: :destroy => { :before => [], :after => [] }, 36: } 37: end
deep copy hooks from the parent model
# File lib/dm-core/model/hook.rb, line 55 55: def copy_hooks(model) 56: hooks = Hash.new do |hooks, name| 57: hooks[name] = Hash.new do |types, type| 58: if self.hooks[name] 59: types[type] = self.hooks[name][type].map do |command| 60: command.copy(model) 61: end 62: end 63: end 64: end 65: 66: model.instance_variable_set(:@hooks, hooks) 67: end
# File lib/dm-core/model/hook.rb, line 41 41: def setup_hook(type, name, method, proc) 42: types = hooks[name] 43: if types && types[type] 44: types[type] << if proc 45: ProcCommand.new(proc) 46: else 47: MethodCommand.new(self, method) 48: end 49: else 50: yield 51: end 52: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.