Sha256: af5ba6f98893f968c08272366907a45f58e9b76ac1966ea6470f2e12203e7a82
Contents?: true
Size: 902 Bytes
Versions: 17
Compression:
Stored size: 902 Bytes
Contents
module NCore module Delete extend ActiveSupport::Concern module ClassMethods def delete!(id, params={}) obj = delete(id, params) if obj.errors? raise module_parent::RecordInvalid, obj end obj end # always returns a new object; check .errors? or .valid? to see how it went def delete(id, params={}) raise(module_parent::RecordNotFound, "Cannot delete id=nil") if id.blank? obj = new(id: id) obj.delete(params) obj end end def delete(params={}) params = parse_request_params(params).reverse_merge credentials: api_creds parsed, @api_creds = request(:delete, resource_path, params) load(parsed) errors.empty? ? self : false end def delete!(params={}) delete(params) || raise(self.class.module_parent::RecordInvalid, self) end end end
Version data entries
17 entries across 17 versions & 1 rubygems