Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/as_csv/csv_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ def to_csv
rows.collect { |row| CSV.generate_line(row, **csv_options) }.join
end

def headers
@headers ||= csv_hashes.collect(&:keys).flatten.uniq
end

private

def rows
@rows ||= [headers] + data_rows
end

def headers
@headers ||= csv_hashes.collect(&:keys).flatten.uniq
end

def data_rows
@data_rows ||= csv_hashes.collect { |csv_hash| data_row csv_hash }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/csv_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
end
end

context 'with hetreogenous records' do
context 'with heterogeneous records' do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏻

let(:records) do
2.times.map do |i|
double(:foo, :as_csv => {
Expand Down