Class: Origami::Importer::Batch
- Inherits:
-
Object
- Object
- Origami::Importer::Batch
- Defined in:
- lib/origami-importer/batch.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#realm ⇒ Object
Returns the value of attribute realm.
-
#remote ⇒ Object
Returns the value of attribute remote.
-
#session ⇒ Object
Returns the value of attribute session.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #client ⇒ Object
- #close(data) ⇒ Object
- #delete ⇒ Object
-
#initialize(options) ⇒ Batch
constructor
A new instance of Batch.
- #open ⇒ Object
- #relay ⇒ Object
- #save(records) ⇒ Object
Constructor Details
#initialize(options) ⇒ Batch
Returns a new instance of Batch.
6 7 8 9 10 11 |
# File 'lib/origami-importer/batch.rb', line 6 def initialize() self.endpoint = [:host] self.realm = [:realm] self.source = [:source] self.session = [:session] end |
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/origami-importer/batch.rb', line 5 def endpoint @endpoint end |
#realm ⇒ Object
Returns the value of attribute realm.
5 6 7 |
# File 'lib/origami-importer/batch.rb', line 5 def realm @realm end |
#remote ⇒ Object
Returns the value of attribute remote.
5 6 7 |
# File 'lib/origami-importer/batch.rb', line 5 def remote @remote end |
#session ⇒ Object
Returns the value of attribute session.
5 6 7 |
# File 'lib/origami-importer/batch.rb', line 5 def session @session end |
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/origami-importer/batch.rb', line 5 def source @source end |
Instance Method Details
#client ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/origami-importer/batch.rb', line 13 def client unless @client origami_host = endpoint Pebblebed.config { host origami_host } @client = Pebblebed::Connector.new(session).origami end @client end |
#close(data) ⇒ Object
35 36 37 38 39 |
# File 'lib/origami-importer/batch.rb', line 35 def close(data) url = "/#{realm}/batches/#{remote.id}/close" puts "posting to #{url}, :relay => #{data.inspect}" client.post url, :relay => data end |
#delete ⇒ Object
41 42 43 |
# File 'lib/origami-importer/batch.rb', line 41 def delete client.delete "/#{realm}/batches/#{remote.id}" end |
#open ⇒ Object
22 23 24 25 |
# File 'lib/origami-importer/batch.rb', line 22 def open result = client.post "/#{realm}/batches", {:batch => {:source => source}} self.remote = result.batch end |
#relay ⇒ Object
27 28 29 |
# File 'lib/origami-importer/batch.rb', line 27 def relay remote.relay || {:previous_import_at => Time.now.utc} end |
#save(records) ⇒ Object
31 32 33 |
# File 'lib/origami-importer/batch.rb', line 31 def save(records) client.post "/#{realm}/batches/#{remote.id}/items", records end |