Class: BomDB::Import::Editions
- Defined in:
- lib/bomdb/import/editions.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#import_json(data, **args) ⇒ Object
Expected data format is: [ [edition_year:Integer, edition_name:String], … ].
Methods inherited from Base
#ensure_parsed_json, #import, #initialize, #schema, tables, #tables
Constructor Details
This class inherits a constructor from BomDB::Import::Base
Instance Method Details
#import_json(data, **args) ⇒ Object
Expected data format is: [
[edition_year:Integer, edition_name:String],
...
]
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bomdb/import/editions.rb', line 13 def import_json(data, **args) data.each do |year, name| @db[:editions].insert( edition_year: year, edition_name: name ) end Import::Result.new(success: true) rescue Sequel::UniqueConstraintViolation => e Import::Result.new(success: false, error: e) end |