Sha256: 2c44d08921dee728dad54610285c26c8a366e426e54016ea2adaf5c22f40960e
Contents?: true
Size: 744 Bytes
Versions: 1
Compression:
Stored size: 744 Bytes
Contents
module Stateflow module Persistence module MongoMapper def self.install(base) base.send :key, self.machine.state_column.to_sym, 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.3 | lib/stateflow/persistence/mongo_mapper.rb |