Sha256: 7a735219631d99558f48fa8fa2e1eea020eb2c1c24be7f0029daacf531abdcbe
Contents?: true
Size: 1.16 KB
Versions: 60
Compression:
Stored size: 1.16 KB
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Querying module Decorator include DynamicQuerying::ClassMethods def model(model=nil) return @model if model.nil? @model = model self end def find!(*ids) raise DocumentNotFound, "Couldn't find without an ID" if ids.size == 0 find(*ids).tap do |result| if result.nil? || ids.size != Array(result).size raise DocumentNotFound, "Couldn't find all of the ids (#{ids.join(',')}). Found #{Array(result).size}, but was expecting #{ids.size}" end end end def all(opts={}) super.map { |doc| model.load(doc) } end def first(opts={}) model.load(super) end def last(opts={}) model.load(super) end private def method_missing(method, *args, &block) return super unless model.respond_to?(method) result = model.send(method, *args, &block) return super unless result.is_a?(Plucky::Query) merge(result) end end end end end
Version data entries
60 entries across 60 versions & 7 rubygems