Class: Insights::API::Common::GraphQL::AssociationLoader

Inherits:
GraphQL::Batch::Loader
  • Object
show all
Defined in:
lib/insights/api/common/graphql/association_loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, association_name, args = {}, graphql_options = {}) ⇒ AssociationLoader

Returns a new instance of AssociationLoader.



8
9
10
11
12
13
# File 'lib/insights/api/common/graphql/association_loader.rb', line 8

def initialize(model, association_name, args = {}, graphql_options = {})
  @model            = model
  @association_name = association_name
  @args             = args
  @graphql_options  = graphql_options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/insights/api/common/graphql/association_loader.rb', line 6

def args
  @args
end

#association_nameObject (readonly)

Returns the value of attribute association_name.



6
7
8
# File 'lib/insights/api/common/graphql/association_loader.rb', line 6

def association_name
  @association_name
end

#graphql_optionsObject (readonly)

Returns the value of attribute graphql_options.



6
7
8
# File 'lib/insights/api/common/graphql/association_loader.rb', line 6

def graphql_options
  @graphql_options
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/insights/api/common/graphql/association_loader.rb', line 6

def model
  @model
end

Instance Method Details

#cache_key(record) ⇒ Object



15
16
17
# File 'lib/insights/api/common/graphql/association_loader.rb', line 15

def cache_key(record)
  record.object_id
end

#perform(records) ⇒ Object



19
20
21
# File 'lib/insights/api/common/graphql/association_loader.rb', line 19

def perform(records)
  records.each { |record| fulfill(record, read_association(record)) }
end