Permalink
Browse files

Fix for workflow error + cosmetic.

Signed-off-by: Chris Toynbee <ctoynbee@gmail.com>
  • Loading branch information...
1 parent 48a617f commit b07aab3a88cb378dc59ea391baa076efeb3ba3bd @ctoynbee committed Apr 30, 2012
Showing with 58 additions and 58 deletions.
  1. +58 −58 lib/trackable_items.rb
View
@@ -16,91 +16,91 @@ def self.included(base)
base.class_eval do
include Workflow
+ workflow do
+ state :waiting_to_be_on_shelf do
+ event :put_on_shelf, :transitions_to => :on_shelf
+ end
+
+ state :on_shelf do
+ event :put_on_display, :transitions_to => :displayed
+ event :hold_out, :transitions_to => :held_out
+ event :loan, :transitions_to => :on_loan_to_organisation
+ end
+
+ state :displayed do
+ event :hold_out, :transitions_to => :held_out
+ event :loan, :transitions_to => :on_loan_to_organisation
+ event :make_ready_to_refile, :transitions_to => :waiting_to_be_refiled
+ end
+
+ state :held_out do
+ event :loan, :transitions_to => :on_loan_to_organisation
+ event :make_ready_to_refile, :transitions_to => :waiting_to_be_refiled
+ end
+
+ state :on_loan_to_organisation do
+ event :put_on_display, :transitions_to => :displayed
+ event :hold_out, :transitions_to => :held_out
+ event :make_ready_to_refile, :transitions_to => :waiting_to_be_refiled
+ end
+
+ # This looks like it might be a state too or a substate of one of the others
+ state :waiting_to_be_refiled do
+ event :put_on_shelf, :transitions_to => :on_shelf
+ # Not sure if it makes sense to be able to go to any other states from here
+ end
- state :waiting_to_be_on_shelf do
- event :put_on_shelf, :transitions_to => :on_shelf
end
-
- state :on_shelf do
- event :put_on_display, :transitions_to => :displayed
- event :hold_out, :transitions_to => :held_out
- event :loan, :transitions_to => :on_loan_to_organisation
- end
-
- state :displayed do
- event :hold_out, :transitions_to => :held_out
- event :loan, :transitions_to => :on_loan_to_organisation
- event :make_ready_to_refile, :transitions_to => :waiting_to_be_refiled
- end
-
- state :held_out do
- event :loan, :transitions_to => :on_loan_to_organisation
- event :make_ready_to_refile, :transitions_to => :waiting_to_be_refiled
- end
-
- state :on_loan_to_organisation do
- event :put_on_display, :transitions_to => :displayed
- event :hold_out, :transitions_to => :held_out
- event :make_ready_to_refile, :transitions_to => :waiting_to_be_refiled
- end
-
- # This looks like it might be a state too or a substate of one of the others
- state :waiting_to_be_refiled do
- event :put_on_shelf, :transitions_to => :on_shelf
- # Not sure if it makes sense to be able to go to any other states from here
- end
-
end
- end
-end
+ end
-module ClassMethods
- def set_up_trackable_items(*args)
- options = args.last.is_a?(Hash) ? args.pop : Hash.new
+ module ClassMethods
+ def set_up_trackable_items(*args)
+ options = args.last.is_a?(Hash) ? args.pop : Hash.new
- # don't allow multiple calls
- return if self.included_modules.include?(TrackableItems::InstanceMethods)
+ # don't allow multiple calls
+ return if self.included_modules.include?(TrackableItems::InstanceMethods)
- send :include, TrackableItems::InstanceMethods
+ send :include, TrackableItems::InstanceMethods
- send :has_many, :shelf_locations
- # not sure if it has many/what about subitems?
- send :has_one, :on_loan_organisations
+ send :has_many, :shelf_locations
+ # not sure if it has many/what about subitems?
+ send :has_one, :on_loan_organisations
- def description_for_tracked_item
+ def description_for_tracked_item
- end
+ end
- # Define workflow methods
- def allocated
+ # Define workflow methods
+ def allocated
- end
+ end
- def display
+ def display
- end
+ end
- def held_out
+ def held_out
- end
+ end
- def on_loan_organisation
+ def on_loan_organisation
- end
+ end
- def to_be_refiled
+ def to_be_refiled
+ end
end
-
end
module InstanceMethods
# could be called is_allocated_to_shelf ?
def has_shelf_location?
true
end
-
-
+
+
end
end

0 comments on commit b07aab3

Please sign in to comment.