From 7d23badb3daffed0baed8dde630a4aa14f338edd Mon Sep 17 00:00:00 2001 From: Zachary Friedman Date: Tue, 7 Apr 2015 17:54:32 -0700 Subject: [PATCH] Pass view_context along to row_attributes proc --- lib/table_cloth/extensions/row_attributes.rb | 4 ++-- lib/table_cloth/presenters/default.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/table_cloth/extensions/row_attributes.rb b/lib/table_cloth/extensions/row_attributes.rb index 8fba9c8..454d634 100644 --- a/lib/table_cloth/extensions/row_attributes.rb +++ b/lib/table_cloth/extensions/row_attributes.rb @@ -21,10 +21,10 @@ def tr_options @tr_options end - def tr_options_for(object) + def tr_options_for(object, view_context) options = tr_options if options.include?(:proc) - result = options[:proc].call(object) || {} + result = options[:proc].call(object, view_context) || {} options.except(:proc).merge(result) else options diff --git a/lib/table_cloth/presenters/default.rb b/lib/table_cloth/presenters/default.rb index ee18d49..2516a70 100644 --- a/lib/table_cloth/presenters/default.rb +++ b/lib/table_cloth/presenters/default.rb @@ -16,7 +16,7 @@ def thead def tbody @tbody ||= ElementFactory::Element.new(:tbody, tag_options(:tbody)).tap do |tbody| - objects.each {|object| tbody << row_for_object(object) } + objects.each {|object| tbody << row_for_object(object, view_context) } end end @@ -32,8 +32,8 @@ def thead_row end end - def row_for_object(object) - tr_options = table.class.tr_options_for(object) + def row_for_object(object, view_context) + tr_options = table.class.tr_options_for(object, view_context) ElementFactory::Element.new(:tr, tag_options(:tr).merge(tr_options)).tap do |row| columns.each do |column|