Class: JSONAPI::Realizer::Action::Index

Inherits:
JSONAPI::Realizer::Action show all
Defined in:
lib/jsonapi/realizer/action/index.rb

Instance Attribute Summary collapse

Attributes inherited from JSONAPI::Realizer::Action

#headers, #payload

Instance Method Summary collapse

Methods inherited from JSONAPI::Realizer::Action

#call, #fields, #includes

Constructor Details

#initialize(payload:, headers:, scope: nil, type:) ⇒ Index

Returns a new instance of Index.



7
8
9
10
11
12
13
# File 'lib/jsonapi/realizer/action/index.rb', line 7

def initialize(payload:, headers:, scope: nil, type:)
  @type = type

  super(payload: payload, headers: headers, scope: scope)

  @resources = adapter.find_many_via_call(relation).map(&resource_class.method(:new))
end

Instance Attribute Details

#resourcesObject

Returns the value of attribute resources.



5
6
7
# File 'lib/jsonapi/realizer/action/index.rb', line 5

def resources
  @resources
end

Instance Method Details

#modelsObject



15
16
17
# File 'lib/jsonapi/realizer/action/index.rb', line 15

def models
  resources.map(&:model)
end