Module: Graphiti::JsonapiSerializableExt::RendererOverrides

Defined in:
lib/graphiti/jsonapi_serializable_ext.rb

Overview

This library looks up a serializer based on the record’s class name This wouldn’t work for us, since a model may be associated with multiple resources. Instead, this variable is assigned when the query is resolved To ensure we always render with the resource serializer

Instance Method Summary collapse

Instance Method Details

#_build(object, exposures, _klass) ⇒ Object



9
10
11
12
13
# File 'lib/graphiti/jsonapi_serializable_ext.rb', line 9

def _build(object, exposures, _klass)
  resource = object.instance_variable_get(:@__graphiti_resource)
  klass = object.instance_variable_get(:@__graphiti_serializer)
  klass.new(exposures.merge(object: object, resource: resource))
end