Sha256: 8c9e14fed8f8e0a24b52a2d35c1fb205f7fe9e77e8e5a1660768b3def623199f
Contents?: true
Size: 700 Bytes
Versions: 1
Compression:
Stored size: 700 Bytes
Contents
module Stateflow module Persistence module MongoMapper def self.install(base) 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.write_attribute(machine.state_column.to_sym, new_state) self.save end def ensure_initial_state send("#{self.machine.state_column.to_s}=", self.current_state.name.to_s) if self.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.2.0 | lib/stateflow/persistence/mongo_mapper.rb |