Class: RestfulError::ExceptionsApp

Inherits:
Object
  • Object
show all
Defined in:
lib/restful_error/exceptions_app.rb

Defined Under Namespace

Classes: Config

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = self.class.config) ⇒ ExceptionsApp

Returns a new instance of ExceptionsApp.



14
15
16
# File 'lib/restful_error/exceptions_app.rb', line 14

def initialize(config = self.class.config)
  @config = config
end

Class Method Details

.configObject



7
8
9
10
11
12
# File 'lib/restful_error/exceptions_app.rb', line 7

def self.config
  @config ||= Config.new.tap do |config|
    config.enable = true
    config.inherit_from = "::ApplicationController"
  end
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
# File 'lib/restful_error/exceptions_app.rb', line 17

def call(env)
  app.call(env)
rescue Exception => _e
  raise unless @config.fallback
  @config.fallback.call(env)
end