Sha256: f59aa1893273e1b62da62f6806fe269d5951577718ff74b07dd849938100b977
Contents?: true
Size: 441 Bytes
Versions: 34
Compression:
Stored size: 441 Bytes
Contents
module Mongoid class Criteria def find_ordered(*ids) ids = Array(ids).flatten return [] if ids.blank? unsorted = any_in(id: ids).to_a ids.map { |id| unsorted.detect { |p| p.id.to_s == id.to_s } }.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
34 entries across 34 versions & 1 rubygems