42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/chop/create.rb', line 42
def create! cucumber_table = table
cucumber_table.hashes.map do |attributes|
attributes = HashWithIndifferentAccess.new(attributes)
attributes = transformations.reduce(attributes) do |attrs, transformation|
transformation.call(attrs)
end
strategy, factory = klass.is_a?(Hash) ? klass.to_a.first : [nil, klass]
args = [factory, attributes]
record = creation_strategies[strategy].call(*args.compact)
after_hooks.each do |after_hook|
after_hook.call(record, attributes.merge(deferred_attributes))
end
record
end
end
|