Class: Dentaku::AST::Map

Inherits:
Enum show all
Defined in:
lib/dentaku/ast/functions/map.rb

Constant Summary

Constants inherited from Function

Function::DIG

Instance Attribute Summary

Attributes inherited from Function

#args

Instance Method Summary collapse

Methods inherited from Enum

#dependencies, #initialize, max_param_count, min_param_count, #validate_identifier

Methods inherited from Function

#accept, #dependencies, get, #initialize, numeric, register, register_class, registry

Methods inherited from Node

arity, #dependencies, #name, precedence, resolve_class, #type

Constructor Details

This class inherits a constructor from Dentaku::AST::Enum

Instance Method Details

#value(context = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/dentaku/ast/functions/map.rb', line 6

def value(context = {})
  collection      = Array(@args[0].value(context))
  item_identifier = @args[1].identifier
  expression      = @args[2]

  collection.map do |item_value|
    mapped_value(expression, context, item_identifier => item_value)
  end
end