Sha256: 091dce3ce5ccd625ad4502a0b9558ea8a8dd6e89335d1f412adaf691de038320

Contents?: true

Size: 702 Bytes

Versions: 15

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

module Grumlin::WithExtension
  def with(name, value)
    prev = self
    strategy = if is_a?(with_step_class)
                 prev = previous_step
                 Grumlin::TraversalStrategies::OptionsStrategy.new(args.first.value.merge(name => value))
               else
                 Grumlin::TraversalStrategies::OptionsStrategy.new({ name => value })
               end
    with_step_class.new(:withStrategies, args: [strategy], previous_step: prev)
  end

  private

  def with_step_class
    @with_step_class ||= Class.new(shortcuts.step_class) do
      include Grumlin::WithExtension

      def with_step_class
        self.class
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
grumlin-1.2.0 lib/grumlin/with_extension.rb
grumlin-1.1.0 lib/grumlin/with_extension.rb
grumlin-1.0.4 lib/grumlin/with_extension.rb
grumlin-1.0.3 lib/grumlin/with_extension.rb
grumlin-1.0.3.beta1 lib/grumlin/with_extension.rb
grumlin-1.0.2 lib/grumlin/with_extension.rb
grumlin-1.0.1 lib/grumlin/with_extension.rb
grumlin-1.0.0 lib/grumlin/with_extension.rb
grumlin-1.0.0.rc7 lib/grumlin/with_extension.rb
grumlin-1.0.0.rc6 lib/grumlin/with_extension.rb
grumlin-1.0.0.rc5 lib/grumlin/with_extension.rb
grumlin-1.0.0.rc4 lib/grumlin/with_extension.rb
grumlin-1.0.0.rc3 lib/grumlin/with_extension.rb
grumlin-1.0.0.rc2 lib/grumlin/with_extension.rb
grumlin-1.0.0.rc1 lib/grumlin/with_extension.rb