lib/grumlin/expressions/p.rb in grumlin-0.15.6 vs lib/grumlin/expressions/p.rb in grumlin-0.16.0

- old
+ new

@@ -1,31 +1,26 @@ # frozen_string_literal: true module Grumlin module Expressions - module P - class << self - class Predicate < TypedValue - def initialize(name, args:, arg_type: nil) - super(type: "P") - @name = name - @args = args - @arg_type = arg_type - end + class P + class Predicate + attr_reader :namespace, :name, :value, :type - def value - @value ||= { - predicate: @name, - value: TypedValue.new(type: @arg_type, value: @args).to_bytecode - } - end + def initialize(namespace, name, value:, type: nil) + @namespace = namespace + @name = name + @value = value + @type = type end + end + class << self # TODO: support more predicates %i[eq neq].each do |predicate| define_method predicate do |*args| - Predicate.new(predicate, args: args[0]) + Predicate.new("P", predicate, value: args[0]) end end %i[within without].each do |predicate| define_method predicate do |*args| @@ -34,10 +29,10 @@ elsif args.count == 1 && args[0].is_a?(Set) args[0].to_a else args.to_a end - Predicate.new(predicate, args: args, arg_type: "List") + Predicate.new("P", predicate, value: args, type: "List") end end end end end