13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/respectable.rb', line 13
def specify_each(table, **options, &block)
desc_template = options.has_key?(:desc) ? options[:desc] : Util.desc_template(block.parameters)
define_method(:specify_each) do |*, &innerblock|
innerblock.call(*@args) if @args
end
@description = ""
Util.table_data(table).each do |row|
desc_data = Hash[block.parameters.map(&:last).zip(row.map(&:inspect))]
@description = desc_template % desc_data if desc_template
instance_eval(<<-IT, *block.source_location)
it(@description) do
@args = Util.eval_row_items(row, binding)
eval(block.source, binding, *block.source_location)
end
IT
end
end
|