Class: JsonApi::Resources::ToOneRelationship
- Inherits:
-
Relationship
- Object
- Relationship
- JsonApi::Resources::ToOneRelationship
- Defined in:
- lib/json_api_ruby/resources/relationships.rb
Overview
convenience classes
Instance Attribute Summary
Attributes inherited from Relationship
#included, #name, #parent, #parent_model, #resources
Instance Method Summary collapse
Methods inherited from Relationship
#included?, #initialize, #links, #to_hash
Constructor Details
This class inherits a constructor from JsonApi::Resources::Relationship
Instance Method Details
#build_resources(options) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/json_api_ruby/resources/relationships.rb', line 86 def build_resources() return unless included? resource_model = parent_model.send(name) return if resource_model.blank? resource_class = Discovery.resource_for_name(resource_model, .merge(parent_resource: parent)) @resources << resource_class.new(resource_model) end |
#data(options = {}) ⇒ Object
81 82 83 84 |
# File 'lib/json_api_ruby/resources/relationships.rb', line 81 def data(={}) identifier_hash = resource_object.identifier_hash if resource_object {'data' => identifier_hash} end |
#resource_object ⇒ Object
95 96 97 |
# File 'lib/json_api_ruby/resources/relationships.rb', line 95 def resource_object @resources.first end |