Class: JSONAPI::Deserializable::Relationship
- Inherits:
-
Object
- Object
- JSONAPI::Deserializable::Relationship
- Extended by:
- DSL
- Defined in:
- lib/jsonapi/deserializable/relationship.rb,
lib/jsonapi/deserializable/relationship/dsl.rb
Defined Under Namespace
Modules: DSL
Constant Summary
Constants included from DSL
DSL::DEFAULT_HAS_MANY_REL_BLOCK, DSL::DEFAULT_HAS_ONE_REL_BLOCK
Class Attribute Summary collapse
-
.has_many_block ⇒ Object
Returns the value of attribute has_many_block.
-
.has_one_block ⇒ Object
Returns the value of attribute has_one_block.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(payload) ⇒ Relationship
constructor
A new instance of Relationship.
- #to_hash ⇒ Object (also: #to_h)
Methods included from DSL
Constructor Details
#initialize(payload) ⇒ Relationship
Returns a new instance of Relationship.
22 23 24 25 26 27 28 |
# File 'lib/jsonapi/deserializable/relationship.rb', line 22 def initialize(payload) @document = payload @data = payload['data'] deserialize! freeze end |
Class Attribute Details
.has_many_block ⇒ Object
Returns the value of attribute has_many_block.
9 10 11 |
# File 'lib/jsonapi/deserializable/relationship.rb', line 9 def has_many_block @has_many_block end |
.has_one_block ⇒ Object
Returns the value of attribute has_one_block.
9 10 11 |
# File 'lib/jsonapi/deserializable/relationship.rb', line 9 def has_one_block @has_one_block end |
Class Method Details
.call(payload) ⇒ Object
18 19 20 |
# File 'lib/jsonapi/deserializable/relationship.rb', line 18 def self.call(payload) new(payload).to_h end |
.inherited(klass) ⇒ Object
12 13 14 15 16 |
# File 'lib/jsonapi/deserializable/relationship.rb', line 12 def self.inherited(klass) super klass.has_one_block = has_one_block klass.has_many_block = has_many_block end |
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
30 31 32 |
# File 'lib/jsonapi/deserializable/relationship.rb', line 30 def to_hash @hash end |