Class: CardDB::Rails::GraphQL::PublisherLoader
- Inherits:
-
GraphQL::Batch::Loader
- Object
- GraphQL::Batch::Loader
- CardDB::Rails::GraphQL::PublisherLoader
- Defined in:
- lib/carddb/rails/graphql/publisher_loader.rb
Instance Method Summary collapse
-
#initialize(client: nil) ⇒ PublisherLoader
constructor
A new instance of PublisherLoader.
- #perform(slugs) ⇒ Object
Constructor Details
#initialize(client: nil) ⇒ PublisherLoader
Returns a new instance of PublisherLoader.
9 10 11 12 |
# File 'lib/carddb/rails/graphql/publisher_loader.rb', line 9 def initialize(client: nil) super() @client = client end |
Instance Method Details
#perform(slugs) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/carddb/rails/graphql/publisher_loader.rb', line 14 def perform(slugs) client = @client || CardDB::Rails.client results = client.batch do |batch| slugs.each do |slug| batch.publishers.fetch(slug: slug) end end slugs.each_with_index do |slug, index| fulfill(slug, results[index]) end end |