module Connect::Record
Public Instance Methods
await_sync(timeout: 25, poll: 5, allocate_sfid_locally: !Rails.env.production?)
click to toggle source
Waits until salesforce allocates an SFID and syncs it back to heroku connect. Persistent failures can occur E.G. if there are duplication rules on the salesforce side.
# File lib/connect/record.rb, line 57 def await_sync(timeout: 25, poll: 5, allocate_sfid_locally: !Rails.env.production?) return true if synced? if allocate_sfid_locally update sfid: SecureRandom.base58(18) else begin Timeout::timeout(timeout) do loop do sleep poll if reload.synced? break end return false if sync_failed? # Bail immediately if sync fails end end rescue Timeout::Error return false end end true end
readonly?()
click to toggle source
Calls superclass method
# File lib/connect/record.rb, line 41 def readonly? return false unless self.class.syncs_to_salesforce? super end
seeding_development_data() { || ... }
click to toggle source
Lets you insert to salesforce tables from tests on an opt-in basis
# File lib/connect/record.rb, line 33 def seeding_development_data old_value = self.syncs_to_salesforce self.syncs_to_salesforce = true yield self.syncs_to_salesforce = old_value end
sync_failed?()
click to toggle source
# File lib/connect/record.rb, line 50 def sync_failed? _hc_err.present? end
synced?()
click to toggle source
# File lib/connect/record.rb, line 46 def synced? _hc_err.blank? && sfid.present? end
syncs_to_salesforce!()
click to toggle source
# File lib/connect/record.rb, line 28 def syncs_to_salesforce! self.syncs_to_salesforce = true end
timestamp_attributes_for_create()
click to toggle source
Automatically update timestamps on save
Calls superclass method
# File lib/connect/record.rb, line 20 def timestamp_attributes_for_create super << "createddate" end
timestamp_attributes_for_update()
click to toggle source
Calls superclass method
# File lib/connect/record.rb, line 24 def timestamp_attributes_for_update super << "systemmodstamp" end