1
0
Fork 0
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:
Zach Gollwitzer 2025-04-01 20:17:57 -04:00
parent 8effdcb2d3
commit 3bc0c18da0
11 changed files with 203 additions and 40 deletions

View 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