Class: Lite::Report::Exporter
- Inherits:
-
Object
- Object
- Lite::Report::Exporter
- Defined in:
- lib/lite/report/exporter.rb
Defined Under Namespace
Classes: NotImplementedError
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(records) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(records) ⇒ Exporter
Returns a new instance of Exporter.
9 10 11 |
# File 'lib/lite/report/exporter.rb', line 9 def initialize(records) @records = records end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
7 8 9 |
# File 'lib/lite/report/exporter.rb', line 7 def records @records end |
Class Method Details
.call(records) ⇒ Object
15 16 17 18 |
# File 'lib/lite/report/exporter.rb', line 15 def call(records) instance = new(records) instance.call end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lite/report/exporter.rb', line 22 def call results = [] if records.respond_to?(:find_each) records.find_each { |record| results << serialize(record) } elsif records.respond_to?(:each) records.each { |record| results << serialize(record) } else results << serialize(records) end results end |