Sha256: e25d7cb68c5e1927272b3670c8f2aeb16c7c014d0b33d1206c6f89b7948307ef
Contents?: true
Size: 855 Bytes
Versions: 4
Compression:
Stored size: 855 Bytes
Contents
class AutoShop < ActiveRecord::Base state_machine :state, :initial => 'available' do after_exit 'available', :increment_customers after_exit 'busy', :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
4 entries across 4 versions & 1 rubygems