Sha256: cf1ac14793c5d30977aeab49b2b96ca26f1936a76ec85cd4db4e13054245a164

Contents?: true

Size: 422 Bytes

Versions: 28

Compression:

Stored size: 422 Bytes

Contents

module Mongoid
  class Criteria
    def find_ordered(*ids)
      ids = Array(ids).flatten
      return [] if ids.blank?

      lookup = scoped.any_in(id: ids).to_lookup_hash
      ids.map { |id| lookup[id] }.compact
    end
  end
end

module Mongoid
  module FindOrdered
    def find_ordered(*args)
      criteria.find_ordered(*args)
    end
  end
end

Mongoid::Document::ClassMethods.send(:include, Mongoid::FindOrdered)

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.6 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.5 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.4 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.3 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.2 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.1 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.0 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.0.beta.1 lib/workarea/ext/mongoid/find_ordered.rb