Class: Dentaku::AST::All

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

Constant Summary

Constants inherited from Function

Function::DIG

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Function

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

Methods inherited from Node

arity, #dependencies, peek, precedence, #type

Constructor Details

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

Class Method Details

.max_param_countObject



11
12
13
# File 'lib/dentaku/ast/functions/all.rb', line 11

def self.max_param_count
  3
end

.min_param_countObject



7
8
9
# File 'lib/dentaku/ast/functions/all.rb', line 7

def self.min_param_count
  3
end

Instance Method Details

#deferred_argsObject



15
16
17
# File 'lib/dentaku/ast/functions/all.rb', line 15

def deferred_args
  [1, 2]
end

#value(context = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dentaku/ast/functions/all.rb', line 19

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

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