Module: Yamori::DmlMethods
- Defined in:
- lib/yamori/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/yamori/dml_methods.rb', line 3 def self.included(c) c.extend ClassMethods end |
Instance Method Details
#delete ⇒ Object
20 21 22 23 24 |
# File 'lib/yamori/dml_methods.rb', line 20 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 |
# File 'lib/yamori/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 self.class.connection.update(self.class.name.to_sym, self.Id, updated_attributes.reject{|_,v| v.nil?}) end @original_attributes = current_attributes.dup @updated_attributes = {} self.Id end |