Class: Restforce::DB::Adapter
- Inherits:
-
Object
- Object
- Restforce::DB::Adapter
- Defined in:
- lib/restforce/db/adapter.rb
Overview
Restforce::DB::Adapter defines the default data conversions between database and Salesforce formats. It translates Dates and Times to ISO-8601 format for storage in Salesforce.
Instance Method Summary collapse
-
#from_database(attributes) ⇒ Object
Public: Convert the passed attribute hash to a format consumable by Salesforce.
-
#to_database(attributes) ⇒ Object
Public: Convert the passed attribute hash to a format consumable by the ActiveRecord model.
Instance Method Details
#from_database(attributes) ⇒ Object
Public: Convert the passed attribute hash to a format consumable by Salesforce.
attributes - A Hash of attributes, with keys corresponding to a Mapping.
Returns a Hash.
26 27 28 29 30 31 32 33 |
# File 'lib/restforce/db/adapter.rb', line 26 def from_database(attributes) attributes.each_with_object({}) do |(key, value), final| value = value.utc if value.respond_to?(:utc) value = value.iso8601 if value.respond_to?(:iso8601) final[key] = value end end |
#to_database(attributes) ⇒ Object
Public: Convert the passed attribute hash to a format consumable by the ActiveRecord model. By default, performs no conversions.
attributes - A Hash of attributes, with keys corresponding to a Mapping.
Returns a Hash.
16 17 18 |
# File 'lib/restforce/db/adapter.rb', line 16 def to_database(attributes) attributes.dup end |