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 ismaster 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.
21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |
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.
40 41 42 |
# File 'lib/mongo/topology_version.rb', line 40 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.
54 55 56 57 58 59 60 |
# File 'lib/mongo/topology_version.rb', line 54 def gt?(other) if process_id != other.process_id true else counter > other.counter 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.
72 73 74 75 76 77 78 |
# File 'lib/mongo/topology_version.rb', line 72 def gte?(other) if process_id != other.process_id true else counter >= other.counter 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.
35 36 37 |
# File 'lib/mongo/topology_version.rb', line 35 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.
85 86 87 |
# File 'lib/mongo/topology_version.rb', line 85 def to_doc BSON::Document.new(self).merge(counter: BSON::Int64.new(counter)) end |