Exception: Merb::ControllerExceptions::Base

Inherits:
StandardError
  • Object
show all
Defined in:
lib/merb-core/controller/exceptions.rb

Overview

:doc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(subclass) ⇒ Object

Registers any subclasses with status codes for easy lookup by set_status in Merb::Controller.

Inheritance ensures this method gets inherited by any subclasses, so it goes all the way down the chain of inheritance.

Parameters

subclass<Merb::ControllerExceptions::Base>

The Exception class that is inheriting from Merb::ControllerExceptions::Base



128
129
130
131
132
# File 'lib/merb-core/controller/exceptions.rb', line 128

def self.inherited(subclass)
  if subclass.const_defined?(:STATUS)
    STATUS_CODES[subclass.name.snake_case.to_sym] = subclass.const_get(:STATUS)
  end
end

.nameObject

Returns

String

The snake cased name of the class without the namespace.



106
107
108
# File 'lib/merb-core/controller/exceptions.rb', line 106

def self.name
  to_s.snake_case.split('::').last
end

.to_iObject

Makes it possible to pass a status-code class to render :status.

Returns

Fixnum

The status code of this exception.



114
115
116
# File 'lib/merb-core/controller/exceptions.rb', line 114

def self.to_i
  STATUS
end

Instance Method Details

#nameObject

Returns

String

The snake cased name of the error without the namespace.



102
# File 'lib/merb-core/controller/exceptions.rb', line 102

def name; self.class.name; end