Class: Tabulard::RowValueBuilder
- Inherits:
-
Object
- Object
- Tabulard::RowValueBuilder
- Includes:
- Utils::MonadicResult
- Defined in:
- lib/tabulard/row_value_builder.rb
Constant Summary
Constants included from Utils::MonadicResult
Instance Method Summary collapse
- #add(column, value) ⇒ Object
-
#initialize(messenger) ⇒ RowValueBuilder
constructor
A new instance of RowValueBuilder.
- #result ⇒ Object
Methods included from Utils::MonadicResult
Constructor Details
#initialize(messenger) ⇒ RowValueBuilder
Returns a new instance of RowValueBuilder.
10 11 12 13 14 15 |
# File 'lib/tabulard/row_value_builder.rb', line 10 def initialize(messenger) @messenger = messenger @data = {} @composites = Set.new @failure = false end |
Instance Method Details
#add(column, value) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tabulard/row_value_builder.rb', line 17 def add(column, value) key = column.key type = column.type index = column.index result = type.scalar(index, value, @messenger) result.bind do |scalar| if type.composite? @composites << [key, type] @data[key] ||= [] @data[key][index] = scalar else @data[key] = scalar end end result.or { @failure = true } result end |