Class: SimpleDataPresentation::SimpleTable::Row
- Defined in:
- lib/simple_data_presentation/simple_table/row.rb
Instance Method Summary collapse
-
#initialize(context, resource, options = {}, &content_block) ⇒ Row
constructor
A new instance of Row.
- #render! ⇒ Object
- #value(*args, &block) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(context, resource, options = {}, &content_block) ⇒ Row
Returns a new instance of Row.
2 3 4 5 6 7 |
# File 'lib/simple_data_presentation/simple_table/row.rb', line 2 def initialize(context, resource, = {}, &content_block) @context = context @resource = resource @options = @content_block = content_block end |
Instance Method Details
#render! ⇒ Object
31 32 33 34 |
# File 'lib/simple_data_presentation/simple_table/row.rb', line 31 def render! content = @context.capture self, &@content_block @context.raw @context.content_tag :tr, content.html_safe, @options[:html] end |
#value(*args, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_data_presentation/simple_table/row.rb', line 9 def value(*args, &block) = args. if block.present? content = @context.capture @resource, &block else if (value_option = [:value]).present? content = value_option.respond_to?(:call) ? value_option.call(@resource) : value_option else content = value_for_method_chain *args end as_formatter = [:as] if as_formatter.present? as_formatter = @context.method(as_formatter).to_proc if as_formatter.is_a?(Symbol) content = case as_formatter.arity when 1; as_formatter.call content when 2; as_formatter.call @resource, content end end end @context.content_tag :td, content, (SimpleDataPresentation::HtmlOptions.new([:html] || {}).merge [:row_html] || {}) end |