Sha256: 61162d1de3a2454c34a467bdd58c101f0db315662300c5a76590671a85f2bcd7

Contents?: true

Size: 1.87 KB

Versions: 139

Compression:

Stored size: 1.87 KB

Contents

# encoding: UTF-8

# --
# Copyright (C) 2008-2011 10gen 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 BSON

  # A class representing the BSON MaxKey type. MaxKey will always compare greater than
  # all other BSON types and values.
  #
  # @example Sorting (assume @numbers is a collection):
  #
  #   >> @numbers.save({"n" => Mongo::MaxKey.new})
  #   >> @numbers.save({"n" => 0})
  #   >> @numbers.save({"n" => 5_000_000})
  #   >> @numbers.find.sort("n").to_a
  #   => [{"_id"=>4b5a050c238d3bace2000004, "n"=>0},
  #       {"_id"=>4b5a04e6238d3bace2000002, "n"=>5_000_000},
  #       {"_id"=>4b5a04ea238d3bace2000003, "n"=>#<Mongo::MaxKey:0x1014ef410>},
  #      ]
  class MaxKey

    def ==(obj)
      obj.class == MaxKey
    end
  end

  # A class representing the BSON MinKey type. MinKey will always compare less than
  # all other BSON types and values.
  #
  # @example Sorting (assume @numbers is a collection):
  #
  #   >> @numbers.save({"n" => Mongo::MinKey.new})
  #   >> @numbers.save({"n" => -1_000_000})
  #   >> @numbers.save({"n" => 1_000_000})
  #   >> @numbers.find.sort("n").to_a
  #   => [{"_id"=>4b5a050c238d3bace2000004, "n"=>#<Mongo::MinKey:0x1014ef410>},
  #       {"_id"=>4b5a04e6238d3bace2000002, "n"=>-1_000_000},
  #       {"_id"=>4b5a04ea238d3bace2000003, "n"=>1_000_000},
  #      ]
  class MinKey

    def ==(obj)
      obj.class == MinKey
    end
  end
end

Version data entries

139 entries across 93 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
classiccms-0.7.5 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.7.4 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
classiccms-0.7.4 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.7.3 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
classiccms-0.7.3 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.7.2 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.7.2 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
classiccms-0.7.1 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.7.1 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
classiccms-0.7.0 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
classiccms-0.7.0 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.6.9 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.6.9 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
bson-1.7.1-java lib/bson/types/min_max_keys.rb
bson-1.7.1 lib/bson/types/min_max_keys.rb
classiccms-0.6.8 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb
classiccms-0.6.8 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.6.7 vendor/bundle/gems/bson-1.6.1/lib/bson/types/min_max_keys.rb
classiccms-0.6.7 vendor/bundle/gems/bson-1.6.2/lib/bson/types/min_max_keys.rb