class MongoModel::Reference
Attributes
id[R]
Public Class Methods
cast(value)
click to toggle source
# File lib/mongomodel/support/reference.rb, line 41 def self.cast(value) case value when BSON::ObjectId new(value) else if BSON::ObjectId.legal?(value.to_s) new(BSON::ObjectId(value.to_s)) else new(value.to_s) end end end
from_mongo(value)
click to toggle source
# File lib/mongomodel/support/reference.rb, line 54 def self.from_mongo(value) cast(value) end
new(id)
click to toggle source
# File lib/mongomodel/support/reference.rb, line 5 def initialize(id) @id = id end
Public Instance Methods
as_json(*)
click to toggle source
# File lib/mongomodel/support/reference.rb, line 19 def as_json(*) to_s end
blank?()
click to toggle source
# File lib/mongomodel/support/reference.rb, line 23 def blank? id.blank? end
eql?(other)
click to toggle source
# File lib/mongomodel/support/reference.rb, line 27 def eql?(other) case other when Reference id.to_s == other.id.to_s else id.to_s == other.to_s end end
Also aliased as: ==
hash()
click to toggle source
# File lib/mongomodel/support/reference.rb, line 15 def hash id.hash end
to_mongo()
click to toggle source
# File lib/mongomodel/support/reference.rb, line 37 def to_mongo id.blank? ? nil : id end
to_s()
click to toggle source
# File lib/mongomodel/support/reference.rb, line 9 def to_s id.to_s end
Also aliased as: to_str