Module: Protip::Resource::Destroyable

Defined in:
lib/protip/resource/destroyable.rb

Overview

Mixin for a resource that has an active ‘:destroy` action. Should be treated as private, and will be included automatically when appropriate.

Instance Method Summary collapse

Instance Method Details

#destroyObject

Raises:

  • (RuntimeError)


6
7
8
9
10
11
12
# File 'lib/protip/resource/destroyable.rb', line 6

def destroy
  raise RuntimeError.new("Can't destroy a non-persisted object") if !persisted?
  self.message = self.class.client.request path: "#{self.class.base_path}/#{id}",
    method: Net::HTTP::Delete,
    message: nil,
    response_type: self.class.message
end