Class: Mongo::TopologyVersion Private
- Inherits:
-
BSON::Document
- Object
- BSON::Document
- Mongo::TopologyVersion
- Defined in:
- lib/mongo/topology_version.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
TopologyVersion encapsulates the topologyVersion document obtained from hello responses and not master-like OperationFailure errors.
Instance Method Summary collapse
-
#counter ⇒ Integer
private
The counter.
-
#gt?(other) ⇒ true | false
private
Returns whether this topology version is potentially newer than another topology version.
-
#gte?(other) ⇒ true | false
private
Returns whether this topology version is potentially newer than or equal to another topology version.
-
#initialize(doc) ⇒ TopologyVersion
constructor
private
A new instance of TopologyVersion.
-
#process_id ⇒ BSON::ObjectId
private
The process id.
-
#to_doc ⇒ BSON::Document
private
Converts the object to a document suitable for being sent to the server.
Constructor Details
#initialize(doc) ⇒ TopologyVersion
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TopologyVersion.
23 24 25 26 27 28 29 30 |
# File 'lib/mongo/topology_version.rb', line 23 def initialize(doc) if Lint.enabled? raise ArgumentError, 'Creating a topology version without processId field' unless doc['processId'] raise ArgumentError, 'Creating a topology version without counter field' unless doc['counter'] end super end |
Instance Method Details
#counter ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The counter.
38 39 40 |
# File 'lib/mongo/topology_version.rb', line 38 def counter self['counter'] end |
#gt?(other) ⇒ true | false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
52 53 54 55 56 57 58 |
# File 'lib/mongo/topology_version.rb', line 52 def gt?(other) if process_id == other.process_id counter > other.counter else true end end |
#gte?(other) ⇒ true | false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
70 71 72 73 74 75 76 |
# File 'lib/mongo/topology_version.rb', line 70 def gte?(other) if process_id == other.process_id counter >= other.counter else true end end |
#process_id ⇒ BSON::ObjectId
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The process id.
33 34 35 |
# File 'lib/mongo/topology_version.rb', line 33 def process_id self['processId'] end |
#to_doc ⇒ BSON::Document
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the object to a document suitable for being sent to the server.
83 84 85 |
# File 'lib/mongo/topology_version.rb', line 83 def to_doc BSON::Document.new(self).merge(counter: BSON::Int64.new(counter)) end |