Module: AASM::Persistence::ActiveFedoraPersistence::InstanceMethods
- Defined in:
- lib/aasm-active_fedora/active_fedora_persistence.rb
Instance Method Summary collapse
- #aasm_ensure_initial_state ⇒ Object
- #aasm_read_state(name = :default) ⇒ Object
- #aasm_write_state(new_state, name = :default) ⇒ Object
- #aasm_write_state_without_persistence(new_state, name = :default) ⇒ Object
Instance Method Details
#aasm_ensure_initial_state ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/aasm-active_fedora/active_fedora_persistence.rb', line 40 def aasm_ensure_initial_state AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |state_machine_name| if send(self.class.aasm(state_machine_name).attribute_name).nil? aasm(state_machine_name).enter_initial_state end end end |
#aasm_read_state(name = :default) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/aasm-active_fedora/active_fedora_persistence.rb', line 48 def aasm_read_state(name=:default) current = send(self.class.aasm(name).attribute_name) return current.to_sym unless current.nil? initial_state = aasm(name).enter_initial_state set_value(self.class.aasm(name).attribute_name, initial_state) return initial_state end |
#aasm_write_state(new_state, name = :default) ⇒ Object
57 58 59 60 |
# File 'lib/aasm-active_fedora/active_fedora_persistence.rb', line 57 def aasm_write_state(new_state, name=:default) aasm_write_state_without_persistence(new_state, name) save end |
#aasm_write_state_without_persistence(new_state, name = :default) ⇒ Object
62 63 64 |
# File 'lib/aasm-active_fedora/active_fedora_persistence.rb', line 62 def aasm_write_state_without_persistence(new_state, name=:default) set_value(self.class.aasm(name).attribute_name, new_state) end |