41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/modis/finder.rb', line 41
def find_all(ids)
raise RecordNotFound, "Couldn't find #{name} without an ID" if ids.empty?
records = Modis.with_connection(modis_connection) do |redis|
if ids.count == 1
ids.map { |id| record_for(redis, id) }
else
redis.pipelined do |pipeline|
ids.map { |id| record_for(pipeline, id) }
end
end
end
models = records_to_models(records)
if models.count < ids.count
missing = ids - models.map(&:id)
raise RecordNotFound, "Couldn't find #{name} with id=#{missing.first}"
end
models
end
|