Composable Conditions
Build complex business logic with all/any/not operators and predicates. Chain conditions naturally with readable DSL syntax.
Separate business logic from code with composable, testable rules. Forward-chaining engine with YAML authoring and full version tracking.
require 'ruleur'
engine = Ruleur.define do
rule 'admin_create', no_loop: true do
conditions do
any?(
user(:admin?),
all?(record(:updatable?), record(:draft?))
)
end
actions do
set :create, true
end
end
rule 'draft_update', no_loop: true do
conditions do
all?(
record(:draft?),
flag(:create)
)
end
actions do
set :update, true
end
end
end
ctx = engine.run(record: record, user: user)
ctx[:create] # => true (if rule fired) or nil
ctx[:update] # => true (if rule fired) or nilWith Ruleur, values are only set when rules fire. If no rule matches, the value remains unset.
Separate Logic from Code - Extract changing business rules from your codebase. Update rules without deploying code.
Testable & Inspectable - Rules are data structures that can be serialized, tested, and debugged independently.
Version Control - Track every change with full audit trails. Roll back bad rules instantly.
Replace Complex Conditionals - Turn nested if/else and Pundit policies into declarative, composable rules.
Database-First - Store rules in your database with YAML authoring. Load and reload at runtime.
VersionedActiveRecordRepository