Module: Control::State
- Defined in:
- lib/control/state.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#next ⇒ Object
Get the next state.
-
#previous ⇒ Object
Get previous state.
-
#workflow ⇒ Object
Gets the workflow associated with state.
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 |
# File 'lib/control/state.rb', line 4 def self.included(base) base.extend(ClassMethods) base.send :before_save, :validate_transition base.send :after_save, :save_transition end |
Instance Method Details
#next ⇒ Object
Get the next state
75 76 77 78 |
# File 'lib/control/state.rb', line 75 def next transition = workflow.transitions.where(:from_class => self.class, :from_id => self.id).first transition.to if transition end |
#previous ⇒ Object
Get previous state
68 69 70 71 |
# File 'lib/control/state.rb', line 68 def previous transition = workflow.transitions.where(:to_class => self.class, :to_id => self.id).first transition.from if transition end |
#workflow ⇒ Object
Gets the workflow associated with state
62 63 64 |
# File 'lib/control/state.rb', line 62 def workflow send self.class.workflow_class.to_s.underscore if self.class.workflow_class end |