end
end
- def import(data, &blk)
+ def import_text(data, &blk)
d = JSON.parse_no_except(data)
return false unless d
res = []
self.transaction do
- self.each_import(d) do |name, item|
+ d.each do |name, item|
m = blk.call(name, item)
res.push(m) unless m.valid?
end
res
end
- def import_file(filename)
+ def import_file(filename, &blk)
t = nil
begin
t = File.open(filename, 'r').read
rescue
return false
end
- self.import t
+ self.import_text t, &blk
end
end