Class: JSONAPI::Ruby::Deserializer::Resource
- Inherits:
-
Object
- Object
- JSONAPI::Ruby::Deserializer::Resource
- Includes:
- Parser
- Defined in:
- lib/jsonapi-ruby-deserializer/resource.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#links ⇒ Object
Returns the value of attribute links.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#relationships ⇒ Object
Returns the value of attribute relationships.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes included from Parser
Instance Method Summary collapse
-
#initialize(data) ⇒ Resource
constructor
A new instance of Resource.
- #parse_attributes!(data) ⇒ Object
- #parse_links!(data) ⇒ Object
- #parse_meta!(data) ⇒ Object
- #parse_relationships!(data) ⇒ Object
Methods included from Parser
Constructor Details
#initialize(data) ⇒ Resource
Returns a new instance of Resource.
12 13 14 15 16 17 18 19 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 12 def initialize(data) @id = data['id'] @type = data['type'] @attributes = parse_attributes!(data['attributes']) @links = parse_links!(data['links']) @meta = (data['meta']) @relationships = parse_relationships!(data['relationships']) end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
10 11 12 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 10 def attributes @attributes end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 10 def id @id end |
#links ⇒ Object
Returns the value of attribute links.
10 11 12 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 10 def links @links end |
#meta ⇒ Object
Returns the value of attribute meta.
10 11 12 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 10 def @meta end |
#relationships ⇒ Object
Returns the value of attribute relationships.
10 11 12 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 10 def relationships @relationships end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 10 def type @type end |
Instance Method Details
#parse_attributes!(data) ⇒ Object
39 40 41 42 43 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 39 def parse_attributes!(data) return if data.nil? || data.empty? Attributes.new(data) end |
#parse_links!(data) ⇒ Object
27 28 29 30 31 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 27 def parse_links!(data) return if data.nil? || data.empty? Links.new(data) end |
#parse_meta!(data) ⇒ Object
33 34 35 36 37 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 33 def (data) return if data.nil? || data.empty? Meta.new(data) end |
#parse_relationships!(data) ⇒ Object
21 22 23 24 25 |
# File 'lib/jsonapi-ruby-deserializer/resource.rb', line 21 def parse_relationships!(data) return if data.nil? || data.empty? Relationships.new(data) end |