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

#payload

Instance Method Summary collapse

Methods inherited from JSONAPI::Realizer::Action

#call

Constructor Details

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

Returns a new instance of Index.



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

def initialize(payload:, headers:, type:)
  @payload = payload
  @headers = headers
  @type = type
  @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



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

def models
  resources.map(&:model)
end