Class: JSONAPI::RelationshipOperationResult

Inherits:
OperationResult show all
Defined in:
lib/jsonapi/operation_result.rb

Instance Attribute Summary collapse

Attributes inherited from OperationResult

#code, #links, #meta, #options, #warnings

Instance Method Summary collapse

Constructor Details

#initialize(code, parent_resource, relationship, resource_ids, options = {}) ⇒ RelationshipOperationResult

Returns a new instance of RelationshipOperationResult.



106
107
108
109
110
111
# File 'lib/jsonapi/operation_result.rb', line 106

def initialize(code, parent_resource, relationship, resource_ids, options = {})
  @parent_resource = parent_resource
  @relationship = relationship
  @resource_ids = resource_ids
  super(code, options)
end

Instance Attribute Details

#parent_resourceObject

Returns the value of attribute parent_resource.



104
105
106
# File 'lib/jsonapi/operation_result.rb', line 104

def parent_resource
  @parent_resource
end

#relationshipObject

Returns the value of attribute relationship.



104
105
106
# File 'lib/jsonapi/operation_result.rb', line 104

def relationship
  @relationship
end

#resource_idsObject

Returns the value of attribute resource_ids.



104
105
106
# File 'lib/jsonapi/operation_result.rb', line 104

def resource_ids
  @resource_ids
end

Instance Method Details

#to_hash(serializer = nil) ⇒ Object



113
114
115
116
117
118
119
120
121
# File 'lib/jsonapi/operation_result.rb', line 113

def to_hash(serializer = nil)
  if serializer
    serializer.serialize_to_relationship_hash(parent_resource, relationship, resource_ids)
  else
    # :nocov:
    {}
    # :nocov:
  end
end