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
#explicit_resource_class, #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
94 95 96 97 98 99 100 101 |
# File 'lib/json_api_ruby/resources/relationships.rb', line 94 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, resource_class: explicit_resource_class)) @resources << resource_class.new(resource_model) end |
#data(options = {}) ⇒ Object
89 90 91 92 |
# File 'lib/json_api_ruby/resources/relationships.rb', line 89 def data(={}) identifier_hash = resource_object.identifier_hash if resource_object {'data' => identifier_hash} end |
#resource_object ⇒ Object
103 104 105 |
# File 'lib/json_api_ruby/resources/relationships.rb', line 103 def resource_object @resources.first end |