Skip to content

RuleurBusiness Rules Engine for Ruby

Separate business logic from code with composable, testable rules. Forward-chaining engine with YAML authoring and full version tracking.

Ruleur Logo

Quick Example ​

ruby
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 nil

With Ruleur, values are only set when rules fire. If no rule matches, the value remains unset.

Why Ruleur? ​

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.

What's New in v1.0 ​

  • βœ… YAML Import/Export - Author rules in YAML for easy database storage
  • βœ… Validation Framework - Structural, semantic, and test execution validation
  • βœ… Version Tracking - Full audit trail with VersionedActiveRecordRepository
  • βœ… Rollback Support - Safe rollback that preserves history
  • βœ… Migration Generator - Easy database setup with provided generators

Get Started β†’

Released under the MIT License.