Class: CardDB::Rails::GraphQL::DeckByExternalRefLoader
- Inherits:
-
GraphQL::Batch::Loader
- Object
- GraphQL::Batch::Loader
- CardDB::Rails::GraphQL::DeckByExternalRefLoader
- Defined in:
- lib/carddb/rails/graphql/deck_loader.rb
Instance Method Summary collapse
-
#initialize(client: nil, read_state: 'DRAFT') ⇒ DeckByExternalRefLoader
constructor
A new instance of DeckByExternalRefLoader.
- #perform(external_refs) ⇒ Object
Constructor Details
#initialize(client: nil, read_state: 'DRAFT') ⇒ DeckByExternalRefLoader
Returns a new instance of DeckByExternalRefLoader.
31 32 33 34 35 |
# File 'lib/carddb/rails/graphql/deck_loader.rb', line 31 def initialize(client: nil, read_state: 'DRAFT') super() @client = client @read_state = read_state end |
Instance Method Details
#perform(external_refs) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/carddb/rails/graphql/deck_loader.rb', line 37 def perform(external_refs) client = @client || CardDB::Rails.client results = client.batch do |batch| external_refs.each do |external_ref| batch.decks.get_by_external_ref(external_ref: external_ref, read_state: @read_state) end end external_refs.each_with_index do |external_ref, index| fulfill(external_ref, results[index]) end end |