Class: Insights::API::Common::GraphQL::AssociationLoader
- Inherits:
-
GraphQL::Batch::Loader
- Object
- GraphQL::Batch::Loader
- Insights::API::Common::GraphQL::AssociationLoader
- Defined in:
- lib/insights/api/common/graphql/association_loader.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#association_name ⇒ Object
readonly
Returns the value of attribute association_name.
-
#graphql_options ⇒ Object
readonly
Returns the value of attribute graphql_options.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #cache_key(record) ⇒ Object
-
#initialize(model, association_name, args = {}, graphql_options = {}) ⇒ AssociationLoader
constructor
A new instance of AssociationLoader.
- #perform(records) ⇒ Object
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 = {}, = {}) @model = model @association_name = association_name @args = args @graphql_options = end |
Instance Attribute Details
#args ⇒ Object (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_name ⇒ Object (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_options ⇒ Object (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 end |
#model ⇒ Object (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 |