Files
whetrails/app/models/order.rb
bill df3f7e1c75
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled
Add core inspector, CLI, and formatter
- Inspector extracts callbacks and validators from any AR model,
  resolves source locations, and filters Rails internals
- CLI: `whetrails inspect <ModelName>` boots Rails and renders chain
- Formatter produces clean lifecycle-ordered terminal output
- Order model added as development fixture

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 10:24:09 -06:00

32 lines
542 B
Ruby

class Order < ApplicationRecord
validates :status, presence: true
validates :total, numericality: { greater_than: 0 }, if: :paid?
before_validation :normalize_status
before_save :calculate_total
after_create :send_confirmation
after_commit :notify_warehouse
private
def normalize_status
self.status = status&.strip&.downcase
end
def calculate_total
# placeholder
end
def send_confirmation
# placeholder
end
def notify_warehouse
# placeholder
end
def paid?
status == "paid"
end
end