Class: JSONAPI::Document::Jsonapi

Inherits:
NameValuePairCollection show all
Defined in:
lib/easy/jsonapi/document/jsonapi.rb,
lib/easy/jsonapi/document/jsonapi/jsonapi_member.rb

Overview

The jsonapi top level member of a JSON:API document

Defined Under Namespace

Classes: JsonapiMember

Instance Method Summary collapse

Methods inherited from NameValuePairCollection

#<<, #to_h, #to_s

Methods inherited from Collection

#[], #[]=, #each, #empty?, #get, #include?, #insert, #keys, #remove, #set, #size, #to_s

Constructor Details

#initialize(jsonapi_member_arr = []) ⇒ Jsonapi

Returns a new instance of Jsonapi.

Parameters:

  • jsonapi_member_arr (Array<JSONAPI::Document::Jsonapi::JsonapiMember] The collection of members to intialize this collection with.) (defaults to: [])

    sonapi_member_arr [Array<JSONAPI::Document::Jsonapi::JsonapiMember] The collection of members to intialize this collection with.



14
15
16
# File 'lib/easy/jsonapi/document/jsonapi.rb', line 14

def initialize(jsonapi_member_arr = [])
  super(jsonapi_member_arr, item_type: JSONAPI::Document::Jsonapi::JsonapiMember)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JSONAPI::NameValuePairCollection

Instance Method Details

#add(jsonapi_member) ⇒ Object

Add a jsonapi member to the collection

Parameters:



20
21
22
# File 'lib/easy/jsonapi/document/jsonapi.rb', line 20

def add(jsonapi_member)
  super(jsonapi_member, &:name)
end