module RSpec::Variants::TabularSyntax

Public Instance Methods

|(other) click to toggle source
# File lib/rspec/variants/tabular.rb, line 7
def |(other)
  # The first two statements are used to get the data_condition block
  # binding as well as the caller instance. The caller instance will be
  # an instance of ExampleGroup.
  data_condition_binding = binding.of_caller(1)
  caller_instance = eval('self', data_condition_binding)

  if caller_instance.instance_variable_defined?(:@__condition_table)
    table = caller_instance.instance_variable_get(:@__condition_table)
  else
    table = RSpec::Variants::Table.new
    caller_instance.instance_variable_set(:@__condition_table, table)
  end

  row = Table::Row.new(self)
  table.add_row(row)
  row.add_condition(other)
  table
end