Module: Gaffe
- Defined in:
- lib/gaffe.rb,
lib/gaffe/errors.rb,
lib/gaffe/version.rb,
lib/gaffe/errors_controller.rb,
lib/gaffe/errors_controller_resolver.rb
Defined Under Namespace
Modules: Errors Classes: ErrorsController, ErrorsControllerResolver
Constant Summary collapse
- VERSION =
'1.2.0'.freeze
Class Method Summary collapse
-
.configuration ⇒ Object
Return the configuration settings.
-
.configure {|configuration| ... } ⇒ Object
Yield a block to populate @configuration.
-
.enable! ⇒ Object
Configure Rails to use our code when encountering exceptions.
-
.errors_controller_for_request(env) ⇒ Object
Return the right errors controller to use for the request that triggered the error.
-
.root ⇒ Object
Return the root path of the gem.
Class Method Details
.configuration ⇒ Object
Return the configuration settings
15 16 17 |
# File 'lib/gaffe.rb', line 15 def self.configuration @configuration ||= OpenStruct.new end |
.configure {|configuration| ... } ⇒ Object
Yield a block to populate @configuration
10 11 12 |
# File 'lib/gaffe.rb', line 10 def self.configure yield configuration end |
.enable! ⇒ Object
Configure Rails to use our code when encountering exceptions
20 21 22 23 24 |
# File 'lib/gaffe.rb', line 20 def self.enable! Rails.application.config.exceptions_app = lambda do |env| Gaffe.errors_controller_for_request(env).action(:show).call(env) end end |
.errors_controller_for_request(env) ⇒ Object
Return the right errors controller to use for the request that triggered the error
28 29 30 31 |
# File 'lib/gaffe.rb', line 28 def self.errors_controller_for_request(env) resolver = ErrorsControllerResolver.new(env) resolver.resolved_controller end |
.root ⇒ Object
Return the root path of the gem
34 35 36 |
# File 'lib/gaffe.rb', line 34 def self.root Pathname.new(File.('../../', __FILE__)) end |