Sha256: 79da9e839b9d71023a626811c76d30a91c887e1a2e3a6f42428b9a5b53ec7495

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

Contents

# Copyright (C) 2014-2015 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 Collection
    class View
      module Immutable

        # @return [ Hash ] options The additional query options.
        attr_reader :options

        private

        # @api private
        #
        # @note In the including class, the method #immutable needs to be
        #   implemented in order to define how a new class of that type needs to
        #   be instantiated.
        def configure(field, value)
          return options[field] if value.nil?
          new(options.merge(field => value))
        end

        def configure_flag(flag)
          new(options.dup).tap do |view|
            view.send(:flags).push(flag)
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mongo-2.1.0.beta lib/mongo/collection/view/immutable.rb
mongo-2.0.6 lib/mongo/collection/view/immutable.rb
mongo-2.0.5 lib/mongo/collection/view/immutable.rb
mongo-2.0.4 lib/mongo/collection/view/immutable.rb
mongo-2.0.3 lib/mongo/collection/view/immutable.rb
mongo-2.0.2 lib/mongo/collection/view/immutable.rb
mongo-2.0.1 lib/mongo/collection/view/immutable.rb
mongo-2.0.0 lib/mongo/collection/view/immutable.rb
mongo-2.0.0.rc lib/mongo/collection/view/immutable.rb
mongo-2.0.0.beta lib/mongo/collection/view/immutable.rb