Module: SObjectModel::DmlMethods
- Defined in:
- lib/sobject_model/dml_methods.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(c) ⇒ Object
3 4 5 |
# File 'lib/sobject_model/dml_methods.rb', line 3 def self.included(c) c.extend ClassMethods end |
Instance Method Details
#delete ⇒ Object
25 26 27 28 29 |
# File 'lib/sobject_model/dml_methods.rb', line 25 def delete return if self.Id.nil? self.class.connection.delete(self.class.name.to_sym, self.Id) end |
#save ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sobject_model/dml_methods.rb', line 7 def save if new_record? self.Id = self.class.connection.create(self.class.name.to_sym, current_attributes.reject{|_,v| v.nil?}) else _updated_attributes = updated_attributes .reject{|_,v| v.nil?} .each_with_object({}){ |(k,v),h| h[k] = (v == :null) ? nil : v } self.class.connection.update(self.class.name.to_sym, self.Id, _updated_attributes) end @original_attributes = current_attributes.dup @updated_attributes = {} self.Id end |