Class: Hook::HookDecorator

Inherits:
MethodDecorator
  • Object
show all
Defined in:
lib/hook.rb

Instance Method Summary collapse

Instance Method Details

#call(wrapped, *args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hook.rb', line 10

def call(wrapped, *args, &block)
  method_name = wrapped.name.to_s
  receiver = wrapped.receiver
  owner = wrapped.owner

  run_hooks owner.around_hooks[method_name], receiver
  run_hooks owner.before_hooks[method_name], receiver
  return_value = wrapped.call *args, &block
  run_hooks owner.after_hooks[method_name], receiver
  run_hooks owner.around_hooks[method_name], receiver

  return_value
end