module Ahub::Deletable

Public Instance Methods

delete(headers:) click to toggle source
# File lib/ahub/modules/deletable.rb, line 12
def delete(headers:)
  self.class.update_node(action: :delete, node_id: id, headers: headers)
end
restore(headers:)
Alias for: undelete
undelete(headers:) click to toggle source
# File lib/ahub/modules/deletable.rb, line 16
def undelete(headers:)
  self.class.update_node(action: :undelete, node_id: id, headers: headers)
end
Also aliased as: restore
update_node(action:, node_id:, headers:) click to toggle source
# File lib/ahub/modules/deletable.rb, line 21
def update_node(action:, node_id:, headers:)
  raise Exception.new('Unknown Action: use :delete or :undelete') unless %i(delete undelete).include?(action)
  url = "#{Ahub::DOMAIN}/services/v2/node/#{node_id}/#{action}.json"

  begin
    response = RestClient.put(url, {}.to_json, headers)
    response.code == 200
  rescue StandardError
    false
  end
end