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
row = datagrid_row(grid, user)
row.first_name # => "<strong>Bogdan</strong>"
row.grid # => Grid object
row.asset # => User object
Instance Attribute Summary collapse
-
#asset ⇒ Object
readonly
Returns the value of attribute asset.
-
#grid ⇒ Object
readonly
Returns the value of attribute grid.
Instance Method Summary collapse
-
#each ⇒ Object
Iterates over all column values that are available in the row.
-
#get(column) ⇒ Object
Return a column value for given column name.
-
#initialize(context, grid, asset) ⇒ HtmlRow
constructor
:nodoc:.
Constructor Details
#initialize(context, grid, asset) ⇒ HtmlRow
:nodoc:
131 132 133 134 135 |
# File 'lib/datagrid/helper.rb', line 131 def initialize(context, grid, asset) # :nodoc: @context = context @grid = grid @asset = asset end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object (protected)
150 151 152 153 154 155 156 |
# File 'lib/datagrid/helper.rb', line 150 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.
129 130 131 |
# File 'lib/datagrid/helper.rb', line 129 def asset @asset end |
#grid ⇒ Object (readonly)
Returns the value of attribute grid.
129 130 131 |
# File 'lib/datagrid/helper.rb', line 129 def grid @grid end |
Instance Method Details
#each ⇒ Object
Iterates over all column values that are available in the row
143 144 145 146 147 |
# File 'lib/datagrid/helper.rb', line 143 def each @grid.columns.each do |column| yield(get(column)) end end |
#get(column) ⇒ Object
Return a column value for given column name
138 139 140 |
# File 'lib/datagrid/helper.rb', line 138 def get(column) @context.datagrid_value(@grid, column, @asset) end |