Sha256: dc87a68d145533b187d5ef1ec830dd9c5f392157c7bd3d7041000ccb20abe957

Contents?: true

Size: 727 Bytes

Versions: 1

Compression:

Stored size: 727 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  module WithExtension
    def with(name, value)
      prev = self
      strategy = if is_a?(with_step_class)
                   prev = previous_step
                   TraversalStrategies::OptionsStrategy.new(args.first.value.merge(name => value))
                 else
                   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 WithExtension

        def with_step_class
          self.class
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grumlin-0.23.0 lib/grumlin/with_extension.rb