Method: CukeModeler::Example#remove_row
- Defined in:
- lib/cuke_modeler/models/example.rb
#remove_row(row) ⇒ Object
Removes a row from the example table. The row can be given as a Hash of parameters and their corresponding values or as an Array of values which will be assigned in order.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cuke_modeler/models/example.rb', line 87 def remove_row(row) return if argument_rows.empty? values = if row.is_a?(Array) row elsif row.is_a?(Hash) # There is no guarantee that the user built up their hash with the keys in the same order as # the parameter row and so the values have to be ordered by us. ordered_row_values(row) else raise(ArgumentError, "Can only remove row from a Hash or an Array but received #{row.class}") end location = index_for_values(values.map(&:to_s).map(&:strip)) @rows.delete_at(location + 1) if location end |