Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pass the row as a hash

  • Loading branch information...
commit 96f549eeaf49120838b521f0397734a45eb01fd8 1 parent 6163031
@nathanl nathanl authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/dossier/result.rb
View
10 lib/dossier/result.rb
@@ -45,19 +45,19 @@ def each
end
end
- def format(result_row)
- unless result_row.kind_of?(Enumerable)
- raise ArgumentError.new("#{result_row.inspect} must be a kind of Enumerable")
+ def format(row)
+ unless row.kind_of?(Enumerable)
+ raise ArgumentError.new("#{row.inspect} must be a kind of Enumerable")
end
- result_row.each_with_index.map do |field, i|
+ row.each_with_index.map do |field, i|
method_name = "format_#{headers[i]}"
if report.respond_to?(method_name)
# Provide the row as context if the formatter takes two arguments
if report.method(method_name).arity == 2
- report.public_send(method_name, field, result_row)
+ report.public_send(method_name, field, Hash[headers.zip(row)])
else
report.public_send(method_name, field)
end
Please sign in to comment.
Something went wrong with that request. Please try again.