Exception: HCast::Errors::AttributeError
- Inherits:
-
HCastError
- Object
- StandardError
- HCastError
- HCast::Errors::AttributeError
- Defined in:
- lib/hcast/errors.rb
Direct Known Subclasses
CastingError, MissingAttributeError, UnexpectedAttributeError
Instance Attribute Summary collapse
-
#namespaces ⇒ Object
readonly
Returns the value of attribute namespaces.
Instance Method Summary collapse
- #add_namespace(namespace) ⇒ Object
-
#initialize(message, namespace = nil) ⇒ AttributeError
constructor
A new instance of AttributeError.
- #message ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message, namespace = nil) ⇒ AttributeError
Returns a new instance of AttributeError.
15 16 17 18 19 |
# File 'lib/hcast/errors.rb', line 15 def initialize(, namespace = nil) super() @namespaces = [] @namespaces << namespace if namespace end |
Instance Attribute Details
#namespaces ⇒ Object (readonly)
Returns the value of attribute namespaces.
13 14 15 |
# File 'lib/hcast/errors.rb', line 13 def namespaces @namespaces end |
Instance Method Details
#add_namespace(namespace) ⇒ Object
21 22 23 |
# File 'lib/hcast/errors.rb', line 21 def add_namespace(namespace) namespaces << namespace end |
#message ⇒ Object
25 26 27 |
# File 'lib/hcast/errors.rb', line 25 def to_s end |
#to_s ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/hcast/errors.rb', line 29 def to_s if namespaces.empty? super else reverted_namespaces = namespaces.reverse msg = reverted_namespaces.first.to_s msg += reverted_namespaces[1..-1].inject("") { |res, item| res += "[#{item}]"} msg + " " + super end end |