Module: SteelWheel::Callbacks

Included in:
Handler
Defined in:
lib/steel_wheel/callbacks.rb

Overview

Provides callbacks functionality for handlers

Constant Summary collapse

NOOP =
->(o) { o }.freeze

Instance Method Summary collapse

Instance Method Details

#callbacksObject



8
9
10
# File 'lib/steel_wheel/callbacks.rb', line 8

def callbacks
  @callbacks ||= {}
end

#failure(*statuses, &block) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/steel_wheel/callbacks.rb', line 12

def failure(*statuses, &block)
  return callbacks[:unprocessable_entity] = block if statuses.empty?

  statuses.each do |status|
    callbacks[status] = block
  end
end

#success(&block) ⇒ Object



20
21
22
# File 'lib/steel_wheel/callbacks.rb', line 20

def success(&block)
  callbacks[:success] = block
end