Module: Reportabull::ClassMethods

Defined in:
lib/reportabull.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#report_builderObject

Returns the value of attribute report_builder.



15
16
17
# File 'lib/reportabull.rb', line 15

def report_builder
  @report_builder
end

Instance Method Details

#columns(options = {}, &block) ⇒ Object



17
18
19
# File 'lib/reportabull.rb', line 17

def columns(options = {}, &block)
  self.report_builder = ReportBuilder.new(options, &block)
end

#to_csv(collection: nil) ⇒ Object



21
22
23
# File 'lib/reportabull.rb', line 21

def to_csv(collection: nil)
  report_builder.build(collection || find_collection, output: '', format: :csv)
end

#to_csv_enumrator(collection: nil) ⇒ Object



25
26
27
28
29
# File 'lib/reportabull.rb', line 25

def to_csv_enumrator(collection: nil)
  Enumerator.new do |y|
    report_builder.build(collection || find_collection, output: y, format: :csv)
  end
end