https://github.com/falm/the_rules
simple rules engine for ruby
https://github.com/falm/the_rules
Last synced: over 1 year ago
JSON representation
simple rules engine for ruby
- Host: GitHub
- URL: https://github.com/falm/the_rules
- Owner: falm
- Created: 2018-05-26T07:52:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-20T11:20:18.000Z (almost 8 years ago)
- Last Synced: 2024-12-31T13:03:33.816Z (over 1 year ago)
- Language: Ruby
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TheRules
**the_rules** is ruby simple rules engine
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'the_rules'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install the_rules
## Usage
### Basic
```ruby
require 'the_rules'
class ServiceObject
include TheRules
rule "age > 18 should be works" do
when? do |data|
data[:age] >= 18
end
then! do |data|
do_something(data[:name])
end
end
rule "married" do
when? do |data|
data[:married]
end
then! do
'Bye!'
end
end
def call
process_rules {name: 'joe', age: 25, married: true}
end
end
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/falm/the_rules.