Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically add conditions to a rule #68

Open
anirudh-dasu opened this issue Jul 6, 2018 · 0 comments
Open

Dynamically add conditions to a rule #68

anirudh-dasu opened this issue Jul 6, 2018 · 0 comments

Comments

@anirudh-dasu
Copy link

Hi,

I have a situation where I need to generate conditions for the rule dynamically based on the user input. For example, this is what am trying to do.

def convert(title, variables)
  engine.rule title do |variables|
    forall {
      has :_, :id, :Id
      variables.each do |v|
        has :Id, v.downcase.to_sym, v.capitalize.to_sym
      end
    }
  end
end 

Similarly for other matchers after has, I want to dynamically set them. However seems like I can't pass any of my variables into the rule block. Is there anyway of doing this? Can I extend the DSL for this functionality? Based on the documentation, it seems that the DSL extension is only for actions. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant