Module: AASM::Persistence::CoreDataQueryPersistence::InstanceMethods

Defined in:
lib/aasm/persistence/core_data_query_persistence.rb

Instance Method Summary collapse

Instance Method Details

#aasm_write_state(state, name = :default) ⇒ Object

Writes state to the state column and persists it to the database using update_attribute (which bypasses validation)

foo = Foo.find(1)
foo.aasm.current_state # => :opened
foo.close!
foo.aasm.current_state # => :closed
Foo.find(1).aasm.current_state # => :closed

NOTE: intended to be called from an event


40
41
42
43
# File 'lib/aasm/persistence/core_data_query_persistence.rb', line 40

def aasm_write_state(state, name=:default)
  raise "Cowardly refusing to save the current CoreDataQuery context"
  aasm_write_state_without_persistence(state, name)
end

#aasm_write_state_without_persistence(state, name = :default) ⇒ Object

Writes state to the state column, but does not persist it to the database

foo = Foo.find(1)
foo.aasm.current_state # => :opened
foo.close
foo.aasm.current_state # => :closed
Foo.find(1).aasm.current_state # => :opened
foo.save
foo.aasm.current_state # => :closed
Foo.find(1).aasm.current_state # => :closed

NOTE: intended to be called from an event


57
58
59
# File 'lib/aasm/persistence/core_data_query_persistence.rb', line 57

def aasm_write_state_without_persistence(state, name=:default)
  write_attribute(self.class.aasm(name).attribute_name, state.to_s)
end