Sha256: 6f659c1cf692c3e9483300e50232596c842a024957f51afc625392f8d21835a2

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  class Step < AnonymousStep
    attr_reader :client

    def initialize(pool, name, *args, previous_steps: [])
      super(name, *args, previous_steps: previous_steps)
      @pool = pool
    end

    def next
      @enum ||= toList.to_enum
      @enum.next
    end

    def toList # rubocop:disable Naming/MethodName
      @pool.acquire do |client|
        client.write(*steps)
      end
    end

    def iterate
      @pool.acquire do |client|
        client.write(*(steps + [nil]))
      end
    end

    private

    def add_step(step_name, args, previous_steps:)
      self.class.new(@pool, step_name, *args, previous_steps: previous_steps)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grumlin-0.4.0 lib/grumlin/step.rb
grumlin-0.3.0 lib/grumlin/step.rb