Sha256: b026da28ed6d7e6ff2705ab34554f383423876c8e2ec93ad9fcb04d2c789a663

Contents?: true

Size: 564 Bytes

Versions: 6

Compression:

Stored size: 564 Bytes

Contents

require_relative './enum'

module Dentaku
  module AST
    class Filter < Enum
      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
    end
  end
end

Dentaku::AST::Function.register_class(:filter, Dentaku::AST::Filter)

Version data entries

6 entries across 6 versions & 2 rubygems

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