Module: Datapathy::Model::Crud

Extended by:
ActiveSupport::Concern
Included in:
Datapathy::Model
Defined in:
lib/datapathy/model/crud.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
# File 'lib/datapathy/model/crud.rb', line 15

def create
  Datapathy::Collection.new(self).create
end

#deleteObject



23
24
25
# File 'lib/datapathy/model/crud.rb', line 23

def delete
  Datapathy::Collection.new(self).delete.first
end

#saveObject



7
8
9
10
11
12
13
# File 'lib/datapathy/model/crud.rb', line 7

def save
  if new_record?
    create()
  else
    update()
  end
end

#updateObject



19
20
21
# File 'lib/datapathy/model/crud.rb', line 19

def update
  Datapathy::Collection.new(self).update(persisted_attributes).first
end