Module: OpenX::Persistance::InstanceMethods

Included in:
Services::Base
Defined in:
lib/openx/persistance.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



55
56
57
58
# File 'lib/openx/persistance.rb', line 55

def destroy
  remote.call(self.class.delete, id)
  @id = nil
end

#save!Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/openx/persistance.rb', line 40

def save!
  params = {}
  self.class.translations.keys.each do |k|
    value = send(:"#{k}")
    params[self.class.translations[k].to_s] = value if value
  end

  if new_record?
    @id = remote.call(self.class.create, params)
  else
    remote.call(self.class.update, params)
  end
  self
end