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.27 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.26 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.25 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.23 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.22 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.21 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.20 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.19 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.18 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.17 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.16 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.15 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.14 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.13 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.12 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.11 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.10 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.9 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.8 lib/workarea/ext/mongoid/find_ordered.rb
workarea-core-3.5.7 lib/workarea/ext/mongoid/find_ordered.rb