Sha256: 00efe18afa07f30776cb6c7bf94dcff2d92c92d40f905e9d1a7c5a03d32ea707

Contents?: true

Size: 739 Bytes

Versions: 9

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

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

    private

    def with_action_class
      @with_action_class ||= Class.new(shortcuts.action_class) do
        include WithExtension

        def with_action_class
          self.class
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
grumlin-0.22.5 lib/grumlin/with_extension.rb
grumlin-0.22.4 lib/grumlin/with_extension.rb
grumlin-0.22.3 lib/grumlin/with_extension.rb
grumlin-0.22.2 lib/grumlin/with_extension.rb
grumlin-0.22.1 lib/grumlin/with_extension.rb
grumlin-0.22.0 lib/grumlin/with_extension.rb
grumlin-0.21.1 lib/grumlin/with_extension.rb
grumlin-0.21.0 lib/grumlin/with_extension.rb
grumlin-0.20.2 lib/grumlin/with_extension.rb