Class: BSON::DBRef

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_odm/core_ext/conversions.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) type_cast(value)



31
32
33
34
35
# File 'lib/mongo_odm/core_ext/conversions.rb', line 31

def self.type_cast(value)
  return value if value.is_a?(BSON::DBRef)
  return value.to_dbref if value.respond_to?(:to_dbref)
  nil
end

Instance Method Details

- (Object) dereference



41
42
43
# File 'lib/mongo_odm/core_ext/conversions.rb', line 41

def dereference
  MongoODM.instanciate(MongoODM.database.dereference(self))
end

- (Boolean) eql?(other) Also known as: ==

Returns:



49
50
51
# File 'lib/mongo_odm/core_ext/conversions.rb', line 49

def eql?(other)
  to_hash == other.to_hash
end

- (Object) inspect



45
46
47
# File 'lib/mongo_odm/core_ext/conversions.rb', line 45

def inspect
  "BSON::DBRef(namespace:\"#{namespace}\", id: \"#{object_id}\")"
end

- (Object) to_mongo



37
38
39
# File 'lib/mongo_odm/core_ext/conversions.rb', line 37

def to_mongo
  self
end