Class: Dentaku::AST::Filter

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

Constant Summary

Constants inherited from Function

Dentaku::AST::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
15
16
17
18
# File 'lib/dentaku/ast/functions/filter.rb', line 6

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

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