1require 'csv'
 
2
 
3class PetitionsCSVPresenter
 
4  attr_reader :petitions, :presenter_class
 
5
  • Complexity 1 » saikuro
6  def initialize(petitions, presenter_class: PetitionCSVPresenter)
 
7    @petitions, @presenter_class = petitions, presenter_class
 
8  end
 
 9
  • DuplicateMethodCall - calls 'presenter_class.fields' 2 times » reek
  • NestedIterators - contains iterators nested 2 deep » reek
  • Complexity 3 » saikuro
10  def render
 
11    Enumerator.new do |stream|
 
12      stream << CSV::Row.new(presenter_class.fields, presenter_class.fields, true).to_s
 
 
14      petitions.in_batches do |petition|
 
15        stream << presenter_class.new(petition).to_csv
 
16      end
 
17    end
 
18  end
 
19end