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