Sha256: 29e2db43a8ffdc4149743b10902f197e9306be72aeaa5cad2619b10582804678
Contents?: true
Size: 967 Bytes
Versions: 7
Compression:
Stored size: 967 Bytes
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 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
7 entries across 7 versions & 2 rubygems