module AASM::Persistence::DynamoidPersistence::InstanceMethods

def aasm_write_state(state, name=:default)

NOTE: intended to be called from an event

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

using update_attribute (which bypasses validation)
Writes state to the state column and persists it to the database
def aasm_write_state(state, name=:default)
  old_value = read_attribute(self.class.aasm(name).attribute_name)
  write_attribute(self.class.aasm(name).attribute_name, state.to_s)
  unless self.save(:validate => false)
    write_attribute(self.class.aasm(name).attribute_name, old_value)
    return false
  end
  true
end