Sha256: b915349d74baaed7da9dae9687d02cfe8e8b256dd6f3a305a7154cedd701257d

Contents?: true

Size: 552 Bytes

Versions: 5

Compression:

Stored size: 552 Bytes

Contents

require_relative './enum'

module Dentaku
  module AST
    class Map < Enum
      def value(context = {})
        collection      = Array(@args[0].value(context))
        item_identifier = @args[1].identifier
        expression      = @args[2]

        collection.map do |item_value|
          expression.value(
            context.merge(
              FlatHash.from_hash_with_intermediates(item_identifier => item_value)
            )
          )
        end
      end
    end
  end
end

Dentaku::AST::Function.register_class(:map, Dentaku::AST::Map)

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
dentaku-3.5.3 lib/dentaku/ast/functions/map.rb
dentaku-3.5.2 lib/dentaku/ast/functions/map.rb
dentaku_zevo-3.5.2 lib/dentaku/ast/functions/map.rb
dentaku-3.5.1 lib/dentaku/ast/functions/map.rb
dentaku-3.5.0 lib/dentaku/ast/functions/map.rb