Sha256: 36f6f387ff0e487d41aa54a9c6363b834350de040363f2d92bb99ef2ea5b5041
Contents?: true
Size: 899 Bytes
Versions: 21
Compression:
Stored size: 899 Bytes
Contents
class AutoShop < ActiveRecord::Base state_machine :state, :initial => 'available' do after_transition :from => 'available', :do => :increment_customers after_transition :from => 'busy', :do => :decrement_customers event :tow_vehicle do transition :to => 'busy', :from => 'available' end event :fix_vehicle do transition :to => 'available', :from => 'busy' end end # Is the Auto Shop available for new customers? def available? state == 'available' end # Is the Auto Shop currently not taking new customers? def busy? state == 'busy' end # Increments the number of customers in service def increment_customers update_attribute(:num_customers, num_customers + 1) end # Decrements the number of customers in service def decrement_customers update_attribute(:num_customers, num_customers - 1) end end
Version data entries
21 entries across 21 versions & 3 rubygems