Class: TableData::CoercingRow
Instance Attribute Summary
Attributes inherited from Row
Instance Method Summary collapse
- #coerce(column, value) ⇒ Object
-
#initialize(table, index, data, coercions) ⇒ CoercingRow
constructor
A new instance of CoercingRow.
Methods inherited from Row
#[], #at, #at_accessor, #at_header, #at_index, #each, #inspect, #method_missing, #respond_to_missing?, #size, #slice, #to_hash, #values_at
Constructor Details
#initialize(table, index, data, coercions) ⇒ CoercingRow
Returns a new instance of CoercingRow.
5 6 7 8 |
# File 'lib/tabledata/coercing_row.rb', line 5 def initialize(table, index, data, coercions) @coercions = coercions super(table, index, data.map.with_index { |value, col| coerce(col, value) }) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class TableData::Row
Instance Method Details
#coerce(column, value) ⇒ Object
10 11 12 13 |
# File 'lib/tabledata/coercing_row.rb', line 10 def coerce(column, value) coercer = @coercions[column] coercer ? coercer.call(value) : value end |