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