Class: LotusAdmin::Exporter
- Inherits:
-
Object
- Object
- LotusAdmin::Exporter
- Defined in:
- app/services/lotus_admin/exporter.rb
Defined Under Namespace
Classes: Column
Class Method Summary collapse
- .generate(*args) ⇒ Object
-
.inherited(other) ⇒ Object
reset so that each subclass has it’s own collection.
- .stream(*args) ⇒ Object
Instance Method Summary collapse
Class Method Details
.generate(*args) ⇒ Object
33 34 35 |
# File 'app/services/lotus_admin/exporter.rb', line 33 def generate(*args) new.generate(*args) end |
.inherited(other) ⇒ Object
reset so that each subclass has it’s own collection
11 12 13 |
# File 'app/services/lotus_admin/exporter.rb', line 11 def self.inherited(other) other._columns = [] end |
.stream(*args) ⇒ Object
29 30 31 |
# File 'app/services/lotus_admin/exporter.rb', line 29 def stream(*args) new.stream(*args) end |
Instance Method Details
#generate(collection) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/services/lotus_admin/exporter.rb', line 52 def generate(collection) @collection = collection CSV.generate do |csv| csv << headers content.each do |row| csv << row end end end |
#stream(collection, stream) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'app/services/lotus_admin/exporter.rb', line 64 def stream(collection, stream) stream.write CSV.generate_line(headers) @collection = collection content.each do |row| stream.write CSV.generate_line(row) end end |