Class: BSON::DBRef

Inherits:
Object show all
Defined in:
lib/jmongo/mongo/bson.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, object_id) ⇒ DBRef

Create a DBRef. Use this class in conjunction with DB#dereference.

Parameters:



117
118
119
120
# File 'lib/jmongo/mongo/bson.rb', line 117

def initialize(namespace, object_id)
  @namespace = namespace
  @object_id = object_id
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



109
110
111
# File 'lib/jmongo/mongo/bson.rb', line 109

def namespace
  @namespace
end

#object_idObject (readonly)

Returns the value of attribute object_id.



109
110
111
# File 'lib/jmongo/mongo/bson.rb', line 109

def object_id
  @object_id
end

Instance Method Details

#to_hashObject



126
127
128
# File 'lib/jmongo/mongo/bson.rb', line 126

def to_hash
  {"$ns" => @namespace, "$id" => @object_id }
end

#to_sObject



122
123
124
# File 'lib/jmongo/mongo/bson.rb', line 122

def to_s
  "ns: #{namespace}, id: #{object_id}"
end