Class: Databasedotcom::Client
- Inherits:
-
Object
- Object
- Databasedotcom::Client
- Defined in:
- lib/capybara_sfdc/databasedotcom/client.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#create(class_or_classname, object_attrs) ⇒ Object
Maybe there’s a better way to do this but overriding the method should work.
- #created ⇒ Object
- #store(sobject) ⇒ Object
Instance Method Details
#cleanup ⇒ Object
26 27 28 29 30 31 |
# File 'lib/capybara_sfdc/databasedotcom/client.rb', line 26 def cleanup created.each do |sobject| sobject.delete end @created = [] end |
#create(class_or_classname, object_attrs) ⇒ Object
Maybe there’s a better way to do this but overriding the method should work
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/capybara_sfdc/databasedotcom/client.rb', line 8 def create(class_or_classname, object_attrs) class_or_classname = find_or_materialize(class_or_classname) json_for_assignment = coerced_json(object_attrs, class_or_classname) result = http_post("/services/data/v#{self.version}/sobjects/#{class_or_classname.sobject_name}", json_for_assignment) new_object = class_or_classname.new JSON.parse(json_for_assignment).each do |property, value| set_value(new_object, property, value, class_or_classname.type_map[property][:type]) end id = JSON.parse(result.body)["id"] set_value(new_object, "Id", id, "id") store(new_object) new_object end |
#created ⇒ Object
33 34 35 |
# File 'lib/capybara_sfdc/databasedotcom/client.rb', line 33 def created @created ||= [] end |
#store(sobject) ⇒ Object
22 23 24 |
# File 'lib/capybara_sfdc/databasedotcom/client.rb', line 22 def store(sobject) created << sobject end |