Class: Datagrid::Helper::HtmlRow
- Inherits:
-
Object
- Object
- Datagrid::Helper::HtmlRow
- Includes:
- Enumerable
- Defined in:
- lib/datagrid/helper.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 ⇒ String
HTML row format.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object (protected)
512 513 514 515 516 517 518 |
# File 'lib/datagrid/helper.rb', line 512 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.
478 479 480 |
# File 'lib/datagrid/helper.rb', line 478 def asset @asset end |
#grid ⇒ Object (readonly)
Returns the value of attribute grid.
478 479 480 |
# File 'lib/datagrid/helper.rb', line 478 def grid @grid end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
478 479 480 |
# File 'lib/datagrid/helper.rb', line 478 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
495 496 497 498 499 |
# File 'lib/datagrid/helper.rb', line 495 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.
489 490 491 |
# File 'lib/datagrid/helper.rb', line 489 def get(column) @renderer.datagrid_value(@grid, column, @asset) end |
#to_s ⇒ String
Returns HTML row format.
502 503 504 505 506 507 508 |
# File 'lib/datagrid/helper.rb', line 502 def to_s @renderer.send(:_render_partial, "row", [:partials], { grid: grid, options: , asset: asset, },) end |