Sha256: 5c837e811dae12b52b00d58bb67c14eb6e824a72eb6edf676e66985e3758cd14
Contents?: true
Size: 718 Bytes
Versions: 1
Compression:
Stored size: 718 Bytes
Contents
module Stateflow module Persistence module MongoMapper def self.install(base) base.send :key, :state, String base.before_validation_on_create :ensure_initial_state base.send :include, InstanceMethods end module InstanceMethods def load_from_persistence self.send machine.state_column.to_sym end def save_to_persistence(new_state) self.update_attributes(machine.state_column.to_sym => new_state) end def ensure_initial_state send("#{self.machine.state_column.to_s}=", self.current_state.name.to_s) if send(self.machine.state_column.to_s).blank? end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stateflow-0.0.2 | lib/stateflow/persistence/mongo_mapper.rb |