Sha256: 233103f421e4b19577b645e8926457ade38aaa7e9e1869d9eee2502e786ca699

Contents?: true

Size: 707 Bytes

Versions: 10

Compression:

Stored size: 707 Bytes

Contents

# frozen-string-literal: true

module Leftovers
  module ValueProcessors
    class EachForDefinitionSet
      def initialize(then_processors)
        @then_processors = then_processors

        freeze
      end

      def process(str, node, method_node)
        definitions = @then_processors.map do |then_processor|
          processed = then_processor.process(str, node, method_node)
          return if processed == :keep # rubocop:disable Lint/NonLocalExitFromIterator

          processed
        end

        definitions.flatten!
        definitions.compact!

        return definitions.first if definitions.length <= 1

        ::Leftovers::DefinitionSet.new(definitions)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
leftovers-0.6.0 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.5.5 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.5.4 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.5.3 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.5.2 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.5.1 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.5.0 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.4.3 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.4.2 lib/leftovers/value_processors/each_for_definition_set.rb
leftovers-0.4.1 lib/leftovers/value_processors/each_for_definition_set.rb