mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Sketch out business logic and basic tests
This commit is contained in:
parent
8effdcb2d3
commit
3bc0c18da0
11 changed files with 203 additions and 40 deletions
11
app/models/rule/condition.rb
Normal file
11
app/models/rule/condition.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class Rule::Condition < ApplicationRecord
|
||||
OPERATORS = [ "and", "or", "gt", "lt", "eq" ]
|
||||
TYPES = [ "match_merchant", "compare_amount", "compound" ]
|
||||
|
||||
belongs_to :rule, optional: true
|
||||
belongs_to :parent, class_name: "Rule::Condition", optional: true
|
||||
has_many :conditions, class_name: "Rule::Condition", foreign_key: :parent_id, dependent: :destroy
|
||||
|
||||
validates :operator, inclusion: { in: OPERATORS }, allow_nil: true
|
||||
validates :condition_type, presence: true, inclusion: { in: TYPES }
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue