Class: Jacoat::Document::Error
- Inherits:
-
Object
- Object
- Jacoat::Document::Error
- Defined in:
- lib/jacoat/document/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(arguments = {}) ⇒ Error
constructor
A new instance of Error.
- #to_hash ⇒ Object
Constructor Details
#initialize(arguments = {}) ⇒ Error
Returns a new instance of Error.
5 6 7 8 9 10 11 12 |
# File 'lib/jacoat/document/error.rb', line 5 def initialize(arguments = {}) @id = arguments[:id] @links = Link.process(arguments[:links]) if arguments.has_key?(:links) %w{ status code title detail }.each do |type| self.instance_variable_set("@#{type}", arguments[type.to_sym]) if arguments.has_key?(type.to_sym) end = Meta.new(arguments[:meta]) if arguments.has_key?(:meta) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/jacoat/document/error.rb', line 4 def code @code end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
4 5 6 |
# File 'lib/jacoat/document/error.rb', line 4 def detail @detail end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/jacoat/document/error.rb', line 4 def id @id end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
4 5 6 |
# File 'lib/jacoat/document/error.rb', line 4 def links @links end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
4 5 6 |
# File 'lib/jacoat/document/error.rb', line 4 def end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/jacoat/document/error.rb', line 4 def status @status end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/jacoat/document/error.rb', line 4 def title @title end |
Instance Method Details
#to_hash ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jacoat/document/error.rb', line 14 def to_hash hash = {} hash[:id] = @id if @id hash[:links] = @links.to_hash if @links %w{ status code title detail }.each do |type| if self.instance_variable_defined?("@#{type}".to_sym) hash[type.to_sym] = instance_variable_get("@#{type}".to_sym) end end hash[:meta] = .to_hash if hash end |