Exception: Merb::ControllerExceptions::Base
- Defined in:
- lib/merb-core/controller/exceptions.rb
Overview
:doc:
Direct Known Subclasses
ClientError, Informational, Redirection, ServerError, Successful
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Registers any subclasses with status codes for easy lookup by set_status in Merb::Controller.
-
.status ⇒ Object
(also: to_i)
Get the actual status-code for an Exception class.
-
.status=(num) ⇒ Object
private
Set the actual status-code for an Exception class.
-
.status? ⇒ Boolean
private
See if a status-code has been defined (on self explicitly).
Instance Method Summary collapse
-
#status ⇒ Object
Returns Integer:: The status-code of the error.
-
#to_i ⇒ Object
Returns Integer:: The status-code of the error.
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
217 218 219 220 221 |
# File 'lib/merb-core/controller/exceptions.rb', line 217 def inherited(subclass) # don't set the constant yet - any class methods will be called after self.inherited # unless self.status = ... is set explicitly, the status code will be inherited register_status_code(subclass, self.status) if self.status? end |
.status ⇒ Object Also known as: to_i
Get the actual status-code for an Exception class.
As usual, this can come from a constant upwards in the inheritance chain.
Returns
- Fixnum
-
The status code of this exception.
171 172 173 |
# File 'lib/merb-core/controller/exceptions.rb', line 171 def status const_get(:STATUS) rescue 0 end |
.status=(num) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the actual status-code for an Exception class.
If possible, set the STATUS constant, and update any previously registered (inherited) status-code.
Parameters
- num<~to_i>
-
The status code
Returns
- (Integer, nil)
-
The status set on this exception, or nil if a status was already set.
188 189 190 191 192 193 |
# File 'lib/merb-core/controller/exceptions.rb', line 188 def status=(num) unless self.status? register_status_code(self, num) self.const_set(:STATUS, num.to_i) end end |
.status? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
See if a status-code has been defined (on self explicitly).
Returns
- Boolean
-
Whether a status code has been set
201 202 203 |
# File 'lib/merb-core/controller/exceptions.rb', line 201 def status? self.const_defined?(:STATUS) end |
Instance Method Details
#status ⇒ Object
Returns
- Integer
-
The status-code of the error.
157 |
# File 'lib/merb-core/controller/exceptions.rb', line 157 def status; self.class.status; end |
#to_i ⇒ Object
Returns
- Integer
-
The status-code of the error.
158 |
# File 'lib/merb-core/controller/exceptions.rb', line 158 def status; self.class.status; end |