Class: JSONAPI::Renderer::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/renderer/document.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Document

Returns a new instance of Document.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jsonapi/renderer/document.rb', line 9

def initialize(params = {})
  @data    = params.fetch(:data,    :no_data)
  @errors  = params.fetch(:errors,  [])
  @meta    = params[:meta]
  @links   = params[:links] || {}
  @fields  = _canonize_fields(params[:fields] || {})
  @jsonapi = params[:jsonapi]
  @include = JSONAPI::IncludeDirective.new(params[:include] || {})
  @relationship = params[:relationship]
  @cache = params[:cache]
end

Instance Method Details

#to_hashObject Also known as: to_h



21
22
23
# File 'lib/jsonapi/renderer/document.rb', line 21

def to_hash
  @hash ||= document_hash
end