Class: Exwiw::RowTransformer::Row
- Inherits:
-
Object
- Object
- Exwiw::RowTransformer::Row
- Defined in:
- lib/exwiw/row_transformer.rb
Overview
The r a map proc receives: read-only access to the current row's
values by column name (r['id']). One instance is reused across all
rows (zero per-row allocation) — do not retain it outside the proc.
Instance Attribute Summary collapse
-
#values ⇒ Object
writeonly
Sets the attribute values.
Instance Method Summary collapse
- #[](column_name) ⇒ Object
-
#initialize(table_name, name_to_index) ⇒ Row
constructor
A new instance of Row.
Constructor Details
#initialize(table_name, name_to_index) ⇒ Row
Returns a new instance of Row.
57 58 59 60 61 |
# File 'lib/exwiw/row_transformer.rb', line 57 def initialize(table_name, name_to_index) @table_name = table_name @name_to_index = name_to_index @values = nil end |
Instance Attribute Details
#values=(value) ⇒ Object (writeonly)
Sets the attribute values
63 64 65 |
# File 'lib/exwiw/row_transformer.rb', line 63 def values=(value) @values = value end |
Instance Method Details
#[](column_name) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/exwiw/row_transformer.rb', line 65 def [](column_name) index = @name_to_index[column_name] unless index raise ArgumentError, "unknown column '#{column_name}' in map proc for table '#{@table_name}' " \ "(available: #{@name_to_index.keys.join(', ')})" end @values[index] end |