Exception: Merb::ControllerExceptions::Base
- Inherits:
-
StandardError
- Object
- StandardError
- Merb::ControllerExceptions::Base
- Defined in:
- merb-core/lib/merb-core/controller/exceptions.rb
Overview
Base class for error codes used in Merb::ControllerExceptions.
Direct Known Subclasses
ClientError, Informational, Redirection, ServerError, Successful
Class Method Summary (collapse)
-
+ (Object) inherited(subclass)
Registers any subclasses with status codes for easy lookup by set_status in Merb::Controller.
-
+ (Fixnum) status
(also: to_i)
Get the actual status-code for an Exception class.
-
+ (Integer?) status=(num)
private
Set the actual status-code for an Exception class.
-
+ (Boolean) status?
private
See if a status-code has been defined (on self explicitly).
Instance Method Summary (collapse)
-
- (Integer) status
The status-code of the error.
-
- (Integer) to_i
The status-code of the error.
Class Method Details
+ (Object) inherited(subclass)
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.
210 211 212 213 214 |
# File 'merb-core/lib/merb-core/controller/exceptions.rb', line 210 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 |
+ (Fixnum) status 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.
168 169 170 |
# File 'merb-core/lib/merb-core/controller/exceptions.rb', line 168 def status const_get(:STATUS) rescue 0 end |
+ (Integer?) status=(num)
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.
184 185 186 187 188 189 |
# File 'merb-core/lib/merb-core/controller/exceptions.rb', line 184 def status=(num) unless self.status? register_status_code(self, num) self.const_set(:STATUS, num.to_i) end end |
+ (Boolean) status?
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).
196 197 198 |
# File 'merb-core/lib/merb-core/controller/exceptions.rb', line 196 def status? self.const_defined?(:STATUS) end |
Instance Method Details
- (Integer) status
The status-code of the error.
155 |
# File 'merb-core/lib/merb-core/controller/exceptions.rb', line 155 def status; self.class.status; end |
- (Integer) to_i
The status-code of the error.
156 |
# File 'merb-core/lib/merb-core/controller/exceptions.rb', line 156 def status; self.class.status; end |