lib/grumlin/step.rb in grumlin-0.2.0 vs lib/grumlin/step.rb in grumlin-0.3.0

- old
+ new

@@ -2,30 +2,34 @@ module Grumlin class Step < AnonymousStep attr_reader :client - def initialize(client, name, *args, previous_steps: []) + def initialize(pool, name, *args, previous_steps: []) super(name, *args, previous_steps: previous_steps) - @client = client + @pool = pool end def next @enum ||= toList.to_enum @enum.next end def toList # rubocop:disable Naming/MethodName - @toList ||= @client.submit(*steps) # rubocop:disable Naming/VariableName + @pool.acquire do |client| + client.write(*steps) + end end def iterate - @client.submit(*(steps + [nil])) + @pool.acquire do |client| + client.write(*(steps + [nil])) + end end private def add_step(step_name, args, previous_steps:) - self.class.new(@client, step_name, *args, previous_steps: previous_steps) + self.class.new(@pool, step_name, *args, previous_steps: previous_steps) end end end