Sha256: 3644e8c1f16e7bc0ec1e5c9f300b8844961503228b9895d9c5e77dada097f598

Contents?: true

Size: 649 Bytes

Versions: 35

Compression:

Stored size: 649 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Contexts #:nodoc:
    module Ids
      # Return documents based on an id search. Will handle if a single id has
      # been passed or mulitple ids.
      #
      # Example:
      #
      #   context.id_criteria([1, 2, 3])
      #
      # Returns:
      #
      # The single or multiple documents.
      def id_criteria(params)
        criteria.id(params)
        result = params.is_a?(Array) ? criteria.entries : one
        if Mongoid.raise_not_found_error
          raise Errors::DocumentNotFound.new(klass, params) if result.blank?
        end
        return result
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 7 rubygems

Version Path
mongoid-1.9.5 lib/mongoid/contexts/ids.rb
mongoid-with-auth-1.9.4 lib/mongoid/contexts/ids.rb
mongoid-rails2-1.9.4 lib/mongoid/contexts/ids.rb
mongoid-rails2-1.9.3 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.20 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.19 lib/mongoid/contexts/ids.rb
mongoid-1.9.2 lib/mongoid/contexts/ids.rb
sskirby-mongoid-1.9.1 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.18 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.17 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.16 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.15 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.14 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.13 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.11 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.10 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.7 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.8 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.9 lib/mongoid/contexts/ids.rb
mongoid-2.0.0.beta.12 lib/mongoid/contexts/ids.rb