module BusinessPipeline::Hooks

Public Class Methods

included(base) click to toggle source
# File lib/business_pipeline/hooks.rb, line 5
def self.included(base)
  base.class_eval do
    extend ClassMethods
  end
end

Private Instance Methods

run_around_hooks(&block) click to toggle source
# File lib/business_pipeline/hooks.rb, line 26
        def run_around_hooks(&block)
  around_hooks = self.class.hooks[:around]

  around_hooks
    .reverse
    .inject(block) { |chain, hook| proc { run_hook(hook, chain) } }
    .call
end
run_hook(hook, *args) click to toggle source
# File lib/business_pipeline/hooks.rb, line 47
        def run_hook(hook, *args)
  hook = method(hook) if hook.is_a?(Symbol)
  hook.call(*args, context, config)
end
run_hooks(type) click to toggle source
# File lib/business_pipeline/hooks.rb, line 43
        def run_hooks(type)
  self.class.hooks[type].each { |hook| run_hook(hook) }
end
with_hooks() { || ... } click to toggle source
# File lib/business_pipeline/hooks.rb, line 35
        def with_hooks
  run_around_hooks do
    run_hooks :before
    yield
    run_hooks :after
  end
end