Method: Amfetamine::QueryMethods#destroy

Defined in:
lib/amfetamine/query_methods.rb

#destroyObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/amfetamine/query_methods.rb', line 133

def destroy
  if self.new?
    return false
  end

  path = self.belongs_to_relationship? ? belongs_to_relationships.first.singular_path : singular_path
  response = self.class.handle_request(:delete, path)

  if handle_response(response)
    clean_cache!
    self.notsaved = true # Because its a new object if the server side got deleted
    self.id = nil # Not saved? No ID.
  end
end