Class: Statum::Hook
- Inherits:
-
Object
- Object
- Statum::Hook
- Defined in:
- lib/statum/hook.rb
Overview
Hook wrapper for Statum::Event
Instance Method Summary collapse
-
#evaluate(instance) ⇒ Object
Execute hook on instane.
-
#initialize(hook) ⇒ Hook
constructor
Creates new Hook instance.
Constructor Details
#initialize(hook) ⇒ Hook
Creates new Hook instance
7 8 9 |
# File 'lib/statum/hook.rb', line 7 def initialize(hook) @hook = hook end |
Instance Method Details
#evaluate(instance) ⇒ Object
Execute hook on instane
14 15 16 17 18 19 20 21 22 |
# File 'lib/statum/hook.rb', line 14 def evaluate(instance) return if @hook.nil? hook = find_hook(instance) if hook.arity.zero? instance.instance_exec(&hook) else instance.instance_exec(instance, &hook) end end |