-
Notifications
You must be signed in to change notification settings - Fork 170
Description
Hi! 👋 This gem looks awesome, thanks for making it. It's a perfect fit for some needs we have to do simple user template evaluation to generate documents. Our use case includes object evaluation, though, and I couldn't see a way for it to work with dentaku. For example, "user.age >= 18, where user is a simple class like this:
class User
attr_reader :age
endI tried doing something like
calculator.store(user: ->{ User.last })
calculator.evaluate("user.age >= 15")
=> nilWe managed to make it work by adding a string representing the object chain...
calculator.store('user.age', ->{ User.last.age })
calculator.evaluate("user.age >= 15")
=> true...but we have hundreds of variations and nestings we'd have to support (like user.profile.default_value) and it wouldn't be practical to generate them all.
Is there a mechanism that would allow for the dot chain evaluation that I missed, maybe some kind of custom evaluator? If not, do you think it would be feasible to add?
(We can also pre-evaluate the values into a string, and then use Dentaku to calculate the final results, but that would unfortunately require a large refactor of our parser and generator, so this seems like the simplest route to start).
Thanks!