TopologyVersion — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::TopologyVersionPrivate

Inherits:

BSON::Document

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 Summarycollapse

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.

24 25 26 27 28 29 30 31 32 33 34 35 # File 'lib/mongo/topology_version.rb', line 24 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.

43 44 45 # File 'lib/mongo/topology_version.rb', line 43 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.

57 58 59 60 61 62 63 # 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

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.

75 76 77 78 79 80 81 # 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_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.

38 39 40 # File 'lib/mongo/topology_version.rb', line 38 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.

88 89 90 # File 'lib/mongo/topology_version.rb', line 88 def to_doc BSON::Document.new(self).merge(counter: BSON::Int64.new(counter)) end