-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I'm thinking of making a stronger DSL for the rules, what do you think of changing this :
def rules
[].tap do |mapping|
mapping << { position: 0, key: 'unknow', allow_blank: true, mappable: false }
mapping << { position: 1, key: 'trade_name', allow_blank: true }
mapping << { position: 2, key: 'company_name', allow_blank: true }
mapping << { position: 3, key: 'example_name_y_3', allow_blank: false }
mapping << { position: 4, key: 'example_name_y_4', allow_blank: true }
mapping << { position: 5, key: 'example_name_y_5', allow_blank: true }
end
end
def definition
@definition ||= Csv2hash::Definition.new rules,
Csv2hash::Definition::COLLECTION,
header_size: 2
endinto this :
collection(header_size: 2) do
cell 0, key: 'unknow', allow_blank: true, mappable: false
cell 1, key: 'trade_name', allow_blank: true
cell 2, key: 'company_name', allow_blank: true
cell 3, key: 'example_name_y_3', allow_blank: false
cell 4, key: 'example_name_y_4', allow_blank: true
cell 5, key: 'example_name_y_5', allow_blank: true
endAnother example :
Mapping and nested rules :
mapping do
cell [0,2], key: 'name'
cell [1,2], key: 'description'
node 'owner' do
cell [3,2], key: 'name', message: 'undefined account :nested on :position'
cell [4,2], key: 'email', message: 'undefined account :key on :position'
end
endAre you ok with this ?
Metadata
Metadata
Assignees
Labels
No labels