Class: Restforce::SObject
- Defined in:
- lib/restforce/sobject.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#attrs ⇒ Object
Public: Returns a hash representation of this object with the attributes key and parent/child relationships removed.
-
#describe ⇒ Object
Public: Get the describe for this sobject type.
-
#describe_layouts(layout_id = nil) ⇒ Object
Public: Describe layouts for this sobject type.
-
#destroy ⇒ Object
Public: Destroy this record.
- #destroy! ⇒ Object
-
#save ⇒ Object
Public: Persist the attributes to Salesforce.
- #save! ⇒ Object
- #sobject_type ⇒ Object
- #to_sparam ⇒ Object
Methods inherited from Mash
build, #convert_value, #dup, #initialize, klass
Constructor Details
This class inherits a constructor from Restforce::Mash
Instance Method Details
#attrs ⇒ Object
Public: Returns a hash representation of this object with the attributes key and parent/child relationships removed.
54 55 56 |
# File 'lib/restforce/sobject.rb', line 54 def attrs self.to_hash.reject { |key, _| key =~ /.*__r/ || key =~ /^attributes$/ } end |
#describe ⇒ Object
Public: Get the describe for this sobject type
10 11 12 |
# File 'lib/restforce/sobject.rb', line 10 def describe @client.describe(sobject_type) end |
#describe_layouts(layout_id = nil) ⇒ Object
Public: Describe layouts for this sobject type
15 16 17 |
# File 'lib/restforce/sobject.rb', line 15 def describe_layouts(layout_id = nil) @client.describe_layouts(sobject_type, layout_id) end |
#destroy ⇒ Object
Public: Destroy this record.
Examples
account = client.query('select Id, Name from Account').first
account.destroy
42 43 44 45 |
# File 'lib/restforce/sobject.rb', line 42 def destroy ensure_id @client.destroy(sobject_type, self.Id) end |
#destroy! ⇒ Object
47 48 49 50 |
# File 'lib/restforce/sobject.rb', line 47 def destroy! ensure_id @client.destroy!(sobject_type, self.Id) end |
#save ⇒ Object
Public: Persist the attributes to Salesforce.
Examples
account = client.query('select Id, Name from Account').first
account.Name = 'Foobar'
account.save
26 27 28 29 |
# File 'lib/restforce/sobject.rb', line 26 def save ensure_id @client.update(sobject_type, attrs) end |
#save! ⇒ Object
31 32 33 34 |
# File 'lib/restforce/sobject.rb', line 31 def save! ensure_id @client.update!(sobject_type, attrs) end |
#sobject_type ⇒ Object
5 6 7 |
# File 'lib/restforce/sobject.rb', line 5 def sobject_type self.attributes['type'] end |
#to_sparam ⇒ Object
58 59 60 |
# File 'lib/restforce/sobject.rb', line 58 def to_sparam self.Id end |