Sha256: 716f61bffe1104fd5af762e0487a1eec3030e6fa0f2f63ca85f67622c9e0995c
Contents?: true
Size: 871 Bytes
Versions: 20
Compression:
Stored size: 871 Bytes
Contents
module Maintain module Backend class DataMapper < Maintain::Backend::Base def aggregate(maintainee, name, attribute, states) # named_scope will handle the array of states as "IN" in SQL state(maintainee, name, attribute, states) end def read(instance, attribute) instance.attributes[attribute.to_s] end def state(maintainee, name, attribute, value) conditions = {:conditions => {attribute => value}} maintainee.class_eval <<-scope def self.#{name} all(#{conditions.inspect}) end scope end def write(instance, attribute, value) property = instance.send(:properties)[attribute] instance.persisted_state = instance.persisted_state.set(property, value) instance.persisted_state.get(property) end end end end
Version data entries
20 entries across 20 versions & 1 rubygems