Sha256: 37111455adf00c94565f79998af66fbdd1358cb5ad86dc8a5b58adfe0007eb4d
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 Bytes
Contents
# 访问LightCloud的加载模块 module ActiveObjectLightCloud def self.included(base) require 'lightcloud' base.send "configurations=", YAML.load_file(base.configurations) if base.configurations.is_a?(String) base.configurations.each do |key,value| lookup_nodes, storage_nodes = LightCloud.generate_nodes(value) LightCloud.init(lookup_nodes, storage_nodes,key) end base.extend ClassMethods base.send :include, InstanceMethods end module ClassMethods def delete(id) LightCloud.delete(self.id_to_key(id)) end private def load(id) raw_record = LightCloud.get(self.id_to_key(id)) || raise(ActiveObject::ObjectNotFound) deserialize_attributes(raw_record) end end module InstanceMethods private def set begin LightCloud.set(@key,serialize_attributes) true rescue false end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activeobject-0.0.3 | ./lib/active_object/adapters/light_cloud.rb |
activeobject-0.0.4 | ./lib/active_object/adapters/light_cloud.rb |