module ActiveForce::Bulk
Constants
- TIMEOUT_MESSAGE
Public Instance Methods
bulk_delete_all(attributes, options={})
click to toggle source
# File lib/active_force/bulk.rb, line 17 def bulk_delete_all(attributes, options={}) run_bulk_job(:delete, attributes, options) end
bulk_insert_all(attributes, options={})
click to toggle source
# File lib/active_force/bulk.rb, line 9 def bulk_insert_all(attributes, options={}) run_bulk_job(:insert, attributes, options) end
bulk_update_all(attributes, options={})
click to toggle source
# File lib/active_force/bulk.rb, line 13 def bulk_update_all(attributes, options={}) run_bulk_job(:update, attributes, options) end
Private Instance Methods
default_options()
click to toggle source
# File lib/active_force/bulk.rb, line 23 def default_options { timeout: 30, sleep: 0.02 # short sleep so we can end our poll loop more quickly } end
run_bulk_job(operation, attributes, options)
click to toggle source
# File lib/active_force/bulk.rb, line 30 def run_bulk_job(operation, attributes, options) runtime_options = default_options.merge(options) records = Records.parse_from_attributes(translate_to_sf(attributes)) job = Job.run(operation: operation, object: self.table_name, records: records) Timeout.timeout(runtime_options[:timeout], ActiveForce::Bulk::TimeoutError, TIMEOUT_MESSAGE % runtime_options) do until job.finished? do job.info sleep(runtime_options[:sleep]) end end job.result end
translate_to_sf(attributes)
click to toggle source
# File lib/active_force/bulk.rb, line 43 def translate_to_sf(attributes) attributes.map{ |r| self.mapping.translate_to_sf(r) } end