Class: ApiPresenter::Resolvers::IncludedCollectionsResolver

Inherits:
Base
  • Object
show all
Defined in:
lib/api_presenter/resolvers/included_collections_resolver.rb

Overview

Handles loading of associated collections and policies, or counts, for the given collection or single record.

Instance Attribute Summary collapse

Attributes inherited from Base

#presenter

Instance Method Summary collapse

Constructor Details

#initialize(presenter) ⇒ IncludedCollectionsResolver

Returns a new instance of IncludedCollectionsResolver.

Parameters:



12
13
14
15
# File 'lib/api_presenter/resolvers/included_collections_resolver.rb', line 12

def initialize(presenter)
  super(presenter)
  preload if relation.is_a?(ActiveRecord::Relation) && resolved_associations_map.any?
end

Instance Attribute Details

#resolved_collectionsObject (readonly)

Returns the value of attribute resolved_collections.



7
8
9
# File 'lib/api_presenter/resolvers/included_collections_resolver.rb', line 7

def resolved_collections
  @resolved_collections
end

Instance Method Details

#callObject



17
18
19
20
# File 'lib/api_presenter/resolvers/included_collections_resolver.rb', line 17

def call
  resolve_collections
  self
end