Sha256: 1b90d69aa3027a28393b6489859c644c675883f6c61af9e02d02f45cb45d07f8

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

#    Copyright 2020 Couchbase, 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.

require 'couchbase/collection'

module Couchbase
  class Scope
    attr_reader :bucket_name
    attr_reader :name

    alias_method :inspect, :to_s

    # @param [Couchbase::Backend] backend
    # @param [String] bucket_name name of the bucket
    # @param [String, :default] scope_name name of the scope
    def initialize(backend, bucket_name, scope_name)
      @backend = backend
      @bucket_name = bucket_name
      @name = scope_name
    end

    # Opens the default collection for this scope
    #
    # @return [Collection]
    def default_collection
      Collection.new(@backend, @bucket_name, @name, :default)
    end

    # Opens the default collection for this scope
    #
    # @param [String] collection_name name of the collection
    #
    # @return [Collection]
    def collection(collection_name)
      Collection.new(@backend, @bucket_name, @name, collection_name)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.1-x86_64-linux lib/couchbase/scope.rb
couchbase-3.0.0.alpha.1-x86_64-darwin-19 lib/couchbase/scope.rb
couchbase-3.0.0.alpha.1-universal-darwin-19 lib/couchbase/scope.rb
couchbase-3.0.0.alpha.1 lib/couchbase/scope.rb