Sha256: d86c7d0df1d56303b1259ae179d2f02b6fbb2899e6d1bfc6d514c146cfcf5f07
Contents?: true
Size: 1.08 KB
Versions: 25
Compression:
Stored size: 1.08 KB
Contents
module SparkApi module Models module Concerns module Destroyable def self.included(base) base.extend(ClassMethods) end module ClassMethods def destroy(id, arguments = {}) connection.delete("#{path}/#{id}", arguments) end end def destroy(arguments = {}) self.errors = [] begin return destroy!(arguments) rescue BadResourceRequest => e self.errors << {:code => e.code, :message => e.message} SparkApi.logger.error("Failed to destroy resource #{self}: #{e.message}") rescue NotFound => e SparkApi.logger.error("Failed to destroy resource #{self}: #{e.message}") end false end def destroy!(arguments = {}) connection.delete(resource_uri, arguments) if persisted? @destroyed = true true end alias_method :delete, :destroy # backwards compatibility def destroyed?; @destroyed ? @destroyed : false end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems