class Mongo::TopologyVersion
TopologyVersion
encapsulates the topologyVersion document obtained from ismaster responses and not master-like OperationFailure errors.
@api private
Public Class Methods
# File lib/mongo/topology_version.rb, line 21 def initialize(doc) if Lint.enabled? unless doc['processId'] raise ArgumentError, 'Creating a topology version without processId field' end unless doc['counter'] raise ArgumentError, 'Creating a topology version without counter field' end end super end
Public Instance Methods
@return [ Integer ] The counter.
# File lib/mongo/topology_version.rb, line 40 def counter self['counter'] end
Returns whether this topology version is potentially newer than another topology version.
Note that there is no total ordering of topology versions - given two topology versions, each may be “potentially newer” than the other one.
@param [ TopologyVersion
] other The other topology version.
@return [ true | false ] Whether this topology version is potentially newer. @api private
# File lib/mongo/topology_version.rb, line 54 def gt?(other) if process_id != other.process_id true else counter > other.counter end end
Returns whether this topology version is potentially newer than or equal to another topology version.
Note that there is no total ordering of topology versions - given two topology versions, each may be “potentially newer” than the other one.
@param [ TopologyVersion
] other The other topology version.
@return [ true | false ] Whether this topology version is potentially newer. @api private
# File lib/mongo/topology_version.rb, line 72 def gte?(other) if process_id != other.process_id true else counter >= other.counter end end
@return [ BSON::ObjectId ] The process id.
# File lib/mongo/topology_version.rb, line 35 def process_id self['processId'] end
Converts the object to a document suitable for being sent to the server.
@return [ BSON::Document ] The document.
@api private
# File lib/mongo/topology_version.rb, line 85 def to_doc BSON::Document.new(self).merge(counter: BSON::Int64.new(counter)) end