Commit cdabd05
Changed files (1)
spec
integration
fixtures
spec/integration/fixtures/movie_mapping.rb
@@ -16,9 +16,7 @@ class MovieMapping
end
def find_all_using(connection, clazz)
- connection[:movies].map do |row|
- Movie.new(row)
- end
+ Results.new(connection[:movies], MovieMapper.new)
end
def run(map)
@@ -26,3 +24,24 @@ class MovieMapping
end
end
+class MovieMapper
+ def map_from(row)
+ Movie.new(row)
+ end
+end
+
+class Results
+ include Enumerable
+
+ def initialize(rows, mapper)
+ @rows = rows
+ @mapper = mapper
+ end
+
+ def each(&block)
+ @rows.each do |row|
+ block.call(@mapper.map_from(row))
+ end
+ end
+end
+