Sha256: 432e8de56e4226010b04b224717deff19cf522d3eab16eeba20ed1b48205f0d4

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

require_relative '../function'
require_relative '../../exceptions'

module Dentaku
  module AST
    class Any < Function
      def self.min_param_count
        3
      end

      def self.max_param_count
        3
      end

      def deferred_args
        [1, 2]
      end

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

        Array(collection).any? 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(:any, Dentaku::AST::Any)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dentaku-3.4.2 lib/dentaku/ast/functions/any.rb