123456789_123456789_123456789_123456789_123456789_

Class: Mongo::TopologyVersion Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, BSON::Document
Instance Chain:
self, BSON::Document
Inherits: BSON::Document
  • Object
Defined in: lib/mongo/topology_version.rb

Overview

TopologyVersion encapsulates the topologyVersion document obtained from hello responses and not master-like OperationFailure errors.

Class Method Summary

Instance Method Summary

Instance Method Details

#counterInteger

Returns:

  • (Integer)

    The counter.

[ GitHub ]

  
# File 'lib/mongo/topology_version.rb', line 43

def counter
  self['counter']
end

#gt?(other) ⇒ true | false

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.

Parameters:

  • other (TopologyVersion)

    The other topology version.

Returns:

  • (true | false)

    Whether this topology version is potentially newer.

[ GitHub ]

  
# File 'lib/mongo/topology_version.rb', line 57

def gt?(other)
  if process_id != other.process_id
    true
  else
    counter > other.counter
  end
end

#gte?(other) ⇒ true | false

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.

Parameters:

  • other (TopologyVersion)

    The other topology version.

Returns:

  • (true | false)

    Whether this topology version is potentially newer.

[ GitHub ]

  
# File 'lib/mongo/topology_version.rb', line 75

def gte?(other)
  if process_id != other.process_id
    true
  else
    counter >= other.counter
  end
end

#process_idBSON::ObjectId

Returns:

  • (BSON::ObjectId)

    The process id.

[ GitHub ]

  
# File 'lib/mongo/topology_version.rb', line 38

def process_id
  self['processId']
end

#to_docBSON::Document

Converts the object to a document suitable for being sent to the server.

Returns:

  • (BSON::Document)

    The document.

[ GitHub ]

  
# File 'lib/mongo/topology_version.rb', line 88

def to_doc
  BSON::Document.new(self).merge(counter: BSON::Int64.new(counter))
end