66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/mongo_mapper.rb', line 66
def dynamic_find(finder, args)
attributes = {}
finder.attributes.each_with_index do |attr, index|
attributes[attr] = args[index]
end
options = args..merge(attributes)
result = find(finder.finder, options)
if result.nil?
if finder.bang
raise DocumentNotFound, "Couldn't find Document with #{attributes.inspect} in collection named #{collection.name}"
end
if finder.instantiator
self.send(finder.instantiator, attributes)
end
else
result
end
end
|