odoyle.rules
*match*
Provides a map of all the matched values from inside a :then block.
This is no longer necessary, because it is accessible via `match` directly.
*session*
Provides the current value of the session from inside a :then or :then-finally block.
This is no longer necessary, because it is accessible via `session` directly.
(->rule rule-name rule)
(->rule [rule-name parsed-rule])
Returns a new rule. In most cases, you should use the `ruleset` macro to define rules,
but if you want to define rules dynamically, you can use this function instead.
See the README section "Defining rules dynamically".
The one-argument arity is only meant for internal use.
(fire-rules session)
(fire-rules session opts)
Fires :then and :then-finally blocks for any rules whose matches have been updated.
The opts map may contain:
:recursion-limit - Throws an error if rules recursively trigger this many times.
The default is 16. Pass nil to disable the limit entirely.
(insert session [id attr value])
(insert session id attr->value)
(insert session id attr value)
Inserts a fact into the session. Can optionally insert multiple facts with the same id.
Note: if the given fact doesn't match at least one rule, it will be discarded.
Examples
Insert facts separately
(->
session
(insert 1 :todo/text "Wash the car")
(insert 1 :todo/done false)
(insert 2 :todo/text "Buy groceries")
(insert 2 :todo/done false)
query-all)
Insert facts batched by id
(->
session
(insert 1 {:todo/text "Wash the car", :todo/done false})
(insert 2 {:todo/text "Buy groceries", :todo/done false})
query-all)
(query-all session)
(query-all session rule-name)
When called with just a session, returns a vector of all inserted facts.
Otherwise, returns a vector of maps containing all the matches for the given rule.
Examples
Query all the facts from the session
Query the matches for a rule
(query-all session :odoyle.examples/get-todo)