Class: Artbase::Base
- Inherits:
-
Object
- Object
- Artbase::Base
- Defined in:
- lib/artbase-importers/collection.rb
Overview
“abstract” Base collection - check -use a different name - why? why not?
Instance Method Summary collapse
Instance Method Details
#import(importer) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/artbase-importers/collection.rb', line 5 def import( importer ) do |, id| puts "==> #{id}" pp .attributes puts h = importer.( .attributes ) ## auto-add id (as intenger) - why? why not? h[ 'id' ] = id img = Image.read( "./#{@slug}/#{@width}x#{@height}/#{id}.png" ) image = "data:image/png;base64, " image += Base64.strict_encode64( img.to_blob ) puts "image:" puts image rec = Database::Metadata.new( h ) rec.image = image ## check for custom callback hooks if importer.respond_to?( :before_save ) importer.before_save( rec ) end rec.save! end end |