9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/simple-excel-import.rb', line 9
def simple_excel_import(role, options = {})
fields = options[:fields]
default = options[:default] || {}
class_eval %(
def self.parse_excel_#{role}(excel_file)
_simple_excel_import(#{fields}, #{default}, excel_file)
end
def self.import_excel_#{role}(excel_file)
models = _simple_excel_import(#{fields}, #{default}, excel_file)
models.each do |model|
model.save
end
models
end
def self.get_sample_excel_#{role}
_simple_excel_import_generate_sample(#{fields}, #{default})
end
)
end
|