Open amattsmith opened 15 years ago
Hi, I have started using Ruleby and I need to do this and I'm getting the error: "Arguments not supported for short-hand conditions" .
I found:
class MethodBuilder
public_instance_methods.each do |m|
a = [:method_missing, :new, :public_instance_methods, :send, :id]
undef_method m.to_sym unless a.include? m.to_sym
end
def method_missing(method_id, *args, &block)
ab = AtomBuilder.new method_id
if block_given?
args.each do |arg|
ab.bindings.push BindingBuilder.new(arg, method_id)
end
ab.block = block
elsif args.size > 0
puts args.class.to_s + ' --- ' + args.to_s
raise 'Arguments not supported for short-hand conditions'
end
return ab
end
end
So I think it is impossible to call a method with params in the conditions; do you know if there is another way to do this? Or how may I edit this collection of methods? Which files do I have to edit?
Thanks in advance, keep rocking!
No, it's not possible to pass the arg because it would mess up the caching mechanism in ruleby (i.e. the result of a method could differ based on the argument).
Instead, you can just a lambda like this:
rule [Fact, :a, where {
lambda {|a| a.is_something?("my_arg")}
}] do |v|
//...
end
hope that helps
On Aug 22, 2012, at 11:31 AM, Pablo Martí wrote:
Hi, I have started using Ruleby and I need to do this and I'm getting the error: "Arguments not supported for short-hand conditions" .
I found:
class MethodBuilder
publicinstance_methods.each do |m| a = [:method_missing, :new, :public_instancemethods, :send, :id] undef_method m.to_sym unless a.include? m.to_sym end
def method_missing(method_id, *args, &block) ab = AtomBuilder.new method_id if block_given? args.each do |arg|
ab.bindings.push BindingBuilder.new(arg, method_id) end ab.block = block elsif args.size > 0 puts args.class.to_s + ' --- ' + args.to_s raise 'Arguments not supported for short-hand conditions' end return ab end end So I think it is impossible to call a method with params in the conditions; do you know if there is another way to do this? Or how may I edit this collection of methods? Which files do I have to edit?Thanks in advance, keep rocking!
— Reply to this email directly or view it on GitHub.
Hey cool! Thank you very much!
Currently, Ruleby does not allow for parameters in method names. For example, the following is not allowed:
[m.get(:name) == ’Joe’]
This needs to be accepted in all syntaxes. Other cases where this is need include:
[m[:name] == ’Joe’]
The Atoms and Nodes are already prepared to accept the arguments. The only area of development needed is in the DSLs.
original LH ticket
This ticket has 0 attachment(s).