Class: Datagrid::Helper::HtmlRow
- Inherits:
-
Object
- Object
- Datagrid::Helper::HtmlRow
- Includes:
- Enumerable
- Defined in:
- lib/datagrid/renderer.rb
Overview
Represents a datagrid row that provides access to column values for the given asset
Instance Attribute Summary collapse
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
-
#grid ⇒ Object
readonly
Returns the value of attribute grid.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Iterates over all column values that are available in the row param block [Proc] column value iterator.
-
#get(column) ⇒ Object
A column value for given column name.
- #to_s ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object (protected)
148 149 150 151 152 153 154 |
# File 'lib/datagrid/renderer.rb', line 148 def method_missing(method, *args, &blk) if column = @grid.column_by_name(method) get(column) else super end end |
Instance Attribute Details
#asset ⇒ Object (readonly)
Returns the value of attribute asset.
116 117 118 |
# File 'lib/datagrid/renderer.rb', line 116 def asset @asset end |
#grid ⇒ Object (readonly)
Returns the value of attribute grid.
116 117 118 |
# File 'lib/datagrid/renderer.rb', line 116 def grid @grid end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
116 117 118 |
# File 'lib/datagrid/renderer.rb', line 116 def @options end |
Instance Method Details
#each(&block) ⇒ Object
Iterates over all column values that are available in the row param block [Proc] column value iterator
133 134 135 136 137 |
# File 'lib/datagrid/renderer.rb', line 133 def each(&block) (@options[:columns] || @grid.html_columns).each do |column| block.call(get(column)) end end |
#get(column) ⇒ Object
Returns a column value for given column name.
127 128 129 |
# File 'lib/datagrid/renderer.rb', line 127 def get(column) @renderer.format_value(@grid, column, @asset) end |
#to_s ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/datagrid/renderer.rb', line 139 def to_s @renderer.send(:_render_partial, 'row', [:partials], { :grid => grid, :options => , :asset => asset }) end |