Sha256: c80d13320b83337f50546d1e5058a4ada2c9e12784259a29e9af0c3877e36716

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

# Copyright (C) 2021 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module Mongo
  class Cursor

    # This class contains the operation specification for KillCursors.
    #
    # Its purpose is to ensure we don't misspell attribute names accidentally.
    #
    # @api private
    class KillSpec

      def initialize(cursor_id:, coll_name:, db_name:, service_id:, server_address:)
        @cursor_id = cursor_id
        @coll_name = coll_name
        @db_name = db_name
        @service_id = service_id
        @server_address = server_address
      end

      attr_reader :cursor_id, :coll_name, :db_name, :service_id, :server_address

      def ==(other)
        cursor_id == other.cursor_id &&
          coll_name == other.coll_name &&
          db_name == other.db_name &&
          service_id == other.service_id &&
          server_address == other.server_address
      end

      def eql?(other)
        self.==(other)
      end

      def hash
        [cursor_id, coll_name, db_name, service_id, server_address].compact.hash
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo-2.17.4 lib/mongo/cursor/kill_spec.rb
mongo-2.17.3 lib/mongo/cursor/kill_spec.rb
mongo-2.17.2 lib/mongo/cursor/kill_spec.rb
mongo-2.17.1 lib/mongo/cursor/kill_spec.rb