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>
This commit is contained in:
31
app/models/order.rb
Normal file
31
app/models/order.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
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
|
||||
Reference in New Issue
Block a user