Class: JSONAPI::Renderer::Document
- Inherits:
-
Object
- Object
- JSONAPI::Renderer::Document
- Defined in:
- lib/jsonapi/renderer/document.rb
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Document
constructor
A new instance of Document.
- #to_hash ⇒ Object (also: #to_h)
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_hash ⇒ Object Also known as: to_h
21 22 23 |
# File 'lib/jsonapi/renderer/document.rb', line 21 def to_hash @hash ||= document_hash end |