class EndpointFlux::Config::RescueFrom

Attributes

exceptions[RW]
handlers[RW]

Public Class Methods

new() click to toggle source
# File lib/endpoint_flux/config/rescue_from.rb, line 6
def initialize
  @handlers   = {}
  @exceptions = []
end

Public Instance Methods

add(klass, &block) click to toggle source
# File lib/endpoint_flux/config/rescue_from.rb, line 17
def add(klass, &block)
  raise 'Block not given' unless block_given?

  handlers[klass.to_s] = block

  exceptions << klass unless exceptions.include?(klass)

  nil
end
run(name, attrs, e) click to toggle source
# File lib/endpoint_flux/config/rescue_from.rb, line 11
def run(name, attrs, e)
  raise 'No handler given' unless exceptions.include?(e.class)

  handlers[e.class.name].call(name, attrs, e)
end