Module: BusinessPipeline::Hooks::ClassMethods

Defined in:
lib/business_pipeline/hooks.rb

Instance Method Summary collapse

Instance Method Details

#add_hooks(*new_hooks, type: __callee__, &block) ⇒ Object Also known as: after, around, before



12
13
14
15
16
# File 'lib/business_pipeline/hooks.rb', line 12

def add_hooks(*new_hooks, type: __callee__, &block)
  hooks[type] += [*new_hooks, block].compact.map do |hook|
    hook.respond_to?(:new) ? hook.new : hook
  end
end

#hooksObject



21
22
23
# File 'lib/business_pipeline/hooks.rb', line 21

def hooks
  @hooks ||= { after: [], around: [], before: [] }
end