class JSONAPI::ResourceFragment

A ResourceFragment holds a ResourceIdentity and associated partial resource data.

The following partial resource data may be stored cache - the value of the cache field for the resource instance related - a hash of arrays of related resource identities, grouped by relationship name related_from - a set of related resource identities that loaded the fragment

Todo: optionally use these for faster responses by bypassing model instantiation) attributes - resource attributes

Attributes

attributes[R]
cache[RW]
cache_field[RW]
identity[R]
primary[RW]

Public Class Methods

new(identity) click to toggle source
# File lib/jsonapi/resource_fragment.rb, line 20
def initialize(identity)
  @identity = identity
  @cache = nil
  @attributes = {}
  @related = {}
  @primary = false
  @related_from = Set.new
end

Public Instance Methods

add_attribute(name, value) click to toggle source
# File lib/jsonapi/resource_fragment.rb, line 43
def add_attribute(name, value)
  @attributes[name] = value
end