Guide
Welcome to the Ruleur guide! This section provides comprehensive documentation on all features and capabilities.
Core Concepts
DSL Basics
Learn the Ruby DSL for defining rules, including all helper methods and shortcuts.
Conditions
Master composable conditions with all/any/not operators and predicate logic.
Operators
Explore all available comparison and logical operators.
Rule Authoring
YAML Rules
Define rules in YAML format for database storage and runtime loading.
Validation
Validate rules before execution with structural, semantic, and test validation.
Persistence & Versioning
Persistence
Store rules in memory or database using repositories.
Versioning & Audit
Track rule changes with full audit trails and rollback support.
Advanced Topics
Advanced Topics
Salience, no-loop, tracing, and performance optimization.
Quick Reference
Common Patterns
ruby
# Permission check
conditions do
any?(user(:admin?), record(:public?))
end
# Ownership check
conditions do
all?(
eq?(record_value(:owner_id), user_value(:id)),
record(:active?)
)
end
# Range check
conditions do
all?(
gte?(record_value(:price), 100),
lte?(record_value(:price), 1000)
)
end
# Array membership
includes(record_value(:roles), literal('editor'))
# Pattern matching
matches(record_value(:email), literal(/\A[\w+\-.]+@[a-z\d-]+(\.[a-z\d-]+)*\.[a-z]+\z/i))DSL Reference
| Method | Description | Example |
|---|---|---|
user(:admin?) | Predicate on user object | user(:admin?) |
record(:active?) | Predicate on record object | record(:active?) |
user_value(:id) | Get field value from user | user_value(:id) |
record_value(:owner_id) | Get field value from record | record_value(:owner_id) |
flag(:create) | Check if permission granted | flag(:create) |
set :update, true | Grant permission | set :update, true |
Operators Reference
Comparison:
eq?(a, b)- Equalnot_eq?(a, b)- Not equalgt?(a, b)- Greater thangte?(a, b)- Greater than or equallt?(a, b)- Less thanlte?(a, b)- Less than or equal
Logical:
truthy?(value)- Value is truthyfalsy?(value)- Value is falsypresent?(value)- Value is present (not nil/empty)blank?(value)- Value is blank (nil/empty)
Collections:
in?(value, array)- Value in arraycontains?(array, value)- Array contains value
Patterns:
matches(string, regex)- String matches regex