Sha256: 3471717e3221bff128e05a9f5722187fa509d5ff6a3a93b6fbc12e64f7be45f2
Contents?: true
Size: 569 Bytes
Versions: 37
Compression:
Stored size: 569 Bytes
Contents
class Object define_method :singleton_class, instance_method(:metaclass) unless respond_to?(:singleton_class) def to_bson(*args) {MongoDoc::BSON::CLASS_KEY => self.class.name}.tap do |bson_hash| instance_variables.each do |name| bson_hash[name[1..-1]] = instance_variable_get(name).to_bson(args) end end end def self.bson_create(bson_hash, options = {}) allocate.tap do |obj| bson_hash.each do |name, value| obj.instance_variable_set("@#{name}", MongoDoc::BSON.decode(value, options)) end end end end
Version data entries
37 entries across 37 versions & 2 rubygems