Module: Origami::Importer
- Defined in:
- lib/origami-importer.rb,
lib/origami-importer/batch.rb,
lib/origami-importer/writer.rb
Defined Under Namespace
Classes: Batch, BatchFailed, Writer
Class Method Summary collapse
Class Method Details
.batch(options = {}, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/origami-importer.rb', line 26 def batch( = {}, &block) host = [:host] realm = [:realm] source = [:source] session = [:session] batch = Batch.new(:host => host, :realm => realm, :source => source, :session => session) reader = [:reader] writer = Writer.new(batch) begin batch.open reader.relay = batch.relay yield reader, writer rescue Pebblebed::HttpError => e puts "Cannot continue. #{e.}" rescue BatchFailed => e puts "Failed. Deleting" batch.delete else puts "Succeeded. Closing." batch.close(reader.relay) end end |