Sha256: b904c50213495f1ec3fa88d1380b59459dcbc6f5ede4618943e79ad8bd67fe1b

Contents?: true

Size: 713 Bytes

Versions: 21

Compression:

Stored size: 713 Bytes

Contents

module JMESPath
  # @api private
  module Nodes
    class MultiSelectHash < Node
      def initialize(kv_pairs)
        @kv_pairs = kv_pairs
      end

      def visit(value)
        if value.nil?
          nil
        else
          @kv_pairs.each_with_object({}) do |pair, hash|
            hash[pair.key] = pair.value.visit(value)
          end
        end
      end

      def optimize
        self.class.new(@kv_pairs.map(&:optimize))
      end

      class KeyValuePair
        attr_reader :key, :value

        def initialize(key, value)
          @key = key
          @value = value
        end

        def optimize
          self.class.new(@key, @value.optimize)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
jmespath-1.6.1 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.6.0 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.5.0 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.4.0 lib/jmespath/nodes/multi_select_hash.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/jmespath-1.3.1/lib/jmespath/nodes/multi_select_hash.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/jmespath-1.3.1/lib/jmespath/nodes/multi_select_hash.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/jmespath-1.3.1/lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.3.1 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.3.0 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.2.4 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.2.3 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.2.2 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.2.1 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.2 lib/jmespath/nodes/multi_select_hash.rb
burtpath-1.1.2 lib/jmespath/nodes/multi_select_hash.rb
burtpath-1.1.1 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.1.3 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.1.2 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.1.1 lib/jmespath/nodes/multi_select_hash.rb
jmespath-1.1.0 lib/jmespath/nodes/multi_select_hash.rb