# File lib/moped/bson/object_id.rb, line 77 def __bson_load__(io) from_data(io.read(12)) end
# File lib/moped/bson/object_id.rb, line 23 def from_data(data) id = allocate id.send(:data=, data) id end
# File lib/moped/bson/object_id.rb, line 10 def from_string(string) raise Errors::InvalidObjectId.new(string) unless legal?(string) from_data [string].pack("H*") end
# File lib/moped/bson/object_id.rb, line 48 def <=>(other) data <=> other.data end
# File lib/moped/bson/object_id.rb, line 43 def ==(other) BSON::ObjectId === other && data == other.data end
# File lib/moped/bson/object_id.rb, line 30 def ===(other) return to_str === other.to_str if other.respond_to?(:to_str) super end
# File lib/moped/bson/object_id.rb, line 82 def __bson_dump__(io, key) io << Types::OBJECT_ID io << key.to_bson_cstring io << data end
# File lib/moped/bson/object_id.rb, line 35 def data # If @data is defined, then we know we've been loaded in some # non-standard way, so we attempt to repair the data. repair! @data if defined? @data @raw_data ||= @@generator.next end
Return the UTC time at which this ObjectId was generated. This may be used instread of a created_at timestamp since this information is always encoded in the object id.
# File lib/moped/bson/object_id.rb, line 72 def generation_time Time.at(data.unpack("N")[0]).utc end
# File lib/moped/bson/object_id.rb, line 61 def inspect to_s.inspect end
@private
# File lib/moped/bson/object_id.rb, line 122 def marshal_dump data end
@private
# File lib/moped/bson/object_id.rb, line 127 def marshal_load(data) self.data = data end
# File lib/moped/bson/object_id.rb, line 65 def to_json(*args) "{\"$oid\": \"#{to_s}\"}" end
# File lib/moped/bson/object_id.rb, line 56 def to_s data.unpack("H*")[0] end
Generated with the Darkfish Rdoc Generator 2.