Module: CartoDB::Model::Persistence

Includes:
Constants
Included in:
Base
Defined in:
lib/cartodb-rb-client/cartodb/model/persistence.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary

Constants included from Constants

Constants::CARTODB_TYPES, Constants::DEFAULT_ROWS_PER_PAGE, Constants::GEOMETRY_COLUMN, Constants::INVALID_COLUMNS, Constants::RGEO_FACTORY

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/cartodb-rb-client/cartodb/model/persistence.rb', line 6

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#destroyObject



28
29
30
31
32
# File 'lib/cartodb-rb-client/cartodb/model/persistence.rb', line 28

def destroy
  unless new_record?
    delete_row
  end
end

#new_record?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/cartodb-rb-client/cartodb/model/persistence.rb', line 34

def new_record?
  cartodb_id.nil? || cartodb_id <= 0
end

#saveObject



20
21
22
23
24
25
26
# File 'lib/cartodb-rb-client/cartodb/model/persistence.rb', line 20

def save
  if new_record?
    create_row
  else
    update_row
  end
end