Module: Workflow::ActiveModelPersistence
- Defined in:
- lib/workflow/active_model_persistence.rb
Class Method Summary collapse
Instance Method Summary collapse
- #load_workflow_state ⇒ Object
-
#persist_workflow_state(new_value) ⇒ Object
On transition the new workflow state is immediately saved in the database.
Class Method Details
.happy_to_be_included_in?(klass) ⇒ Boolean
4 5 6 |
# File 'lib/workflow/active_model_persistence.rb', line 4 def self.happy_to_be_included_in?(klass) Object.const_defined?(:ActiveRecord) and klass.is_a? ActiveRecord::Base end |
.included(klass) ⇒ Object
8 9 10 |
# File 'lib/workflow/active_model_persistence.rb', line 8 def self.included(klass) klass.before_validation :write_initial_state end |
Instance Method Details
#load_workflow_state ⇒ Object
12 13 14 |
# File 'lib/workflow/active_model_persistence.rb', line 12 def load_workflow_state read_attribute(self.class.workflow_column) end |
#persist_workflow_state(new_value) ⇒ Object
On transition the new workflow state is immediately saved in the database.
18 19 20 |
# File 'lib/workflow/active_model_persistence.rb', line 18 def persist_workflow_state(new_value) update_attribute self.class.workflow_column, new_value end |