Module: Chore::Hooks

Defined in:
lib/chore/hooks.rb

Overview

Abstracts the notion of registering and running hooks during certain points in the lifecycle of chore processing work.

Instance Method Summary collapse

Instance Method Details

#run_hooks_for(event, *args) ⇒ Object

Helper method to look up, and execute hooks based on an event name. Hooks are assumed to be methods defined on `self` that are of the pattern hook_name_identifier. ex: before_perform_log



9
10
11
12
13
14
# File 'lib/chore/hooks.rb', line 9

def run_hooks_for(event,*args)
  results = global_hooks_for(event).map { |prc| prc.call(*args) } || [true]
  results << hooks_for(event).map { |method| send(method,*args) }
  results = false if results.any? {|r| false == r }
  results
end