Sha256: f0d17051afea4ed9889d4dc310ddd985904c39104633b463088d3e506ae5ecf9

Contents?: true

Size: 939 Bytes

Versions: 2

Compression:

Stored size: 939 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  class Traversal
    SUPPORTED_STEPS = Grumlin.definitions.dig(:steps, :start).map(&:to_sym).freeze

    CONFIGURATION_STEPS = Grumlin.definitions.dig(:steps, :configuration).map(&:to_sym).freeze

    attr_reader :configuration_steps

    def initialize(pool = Grumlin.default_pool, configuration_steps: [])
      @pool = pool
      @configuration_steps = configuration_steps
    end

    def inspect
      "#<#{self.class}>"
    end

    def to_s
      inspect
    end

    CONFIGURATION_STEPS.each do |step|
      define_method step do |*args, **params|
        self.class.new(@pool, configuration_steps: @configuration_steps + [AnonymousStep.new(step, *args, **params)])
      end
    end

    SUPPORTED_STEPS.each do |step|
      define_method step do |*args, **params|
        Step.new(@pool, step, *args, configuration_steps: @configuration_steps, **params)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grumlin-0.15.6 lib/grumlin/traversal.rb
grumlin-0.15.4 lib/grumlin/traversal.rb