Class: GnListResolver::Resolver
- Inherits:
-
Object
- Object
- GnListResolver::Resolver
- Defined in:
- lib/gn_list_resolver/resolver.rb
Overview
Sends data to GN Resolver and collects results
Constant Summary collapse
- GRAPHQL =
GnGraphQL.new
- QUERY =
GRAPHQL.client.parse(GRAPHQL.query)
Instance Attribute Summary collapse
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
-
#initialize(writer, opts) ⇒ Resolver
constructor
A new instance of Resolver.
- #resolve(data) ⇒ Object
Constructor Details
#initialize(writer, opts) ⇒ Resolver
Returns a new instance of Resolver.
12 13 14 15 16 17 18 19 |
# File 'lib/gn_list_resolver/resolver.rb', line 12 def initialize(writer, opts) instance_vars_from_opts(opts) @processor = GnListResolver::ResultProcessor. new(writer, @stats, @with_classification) @count = 0 @jobs = [] @batch = 1000 end |
Instance Attribute Details
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
10 11 12 |
# File 'lib/gn_list_resolver/resolver.rb', line 10 def stats @stats end |
Instance Method Details
#resolve(data) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gn_list_resolver/resolver.rb', line 21 def resolve(data) resolution_stats(data.size) @threads.times do batch = data.shift(@batch) add_job(batch) end block_given? ? traverse_jobs(data, &Proc.new) : traverse_jobs(data) wrap_up block_given? ? yield(@stats.stats) : @stats.stats end |