- 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>
32 lines
542 B
Ruby
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
|