Class: OData::DeleteOperation

Inherits:
Operation show all
Defined in:
lib/odata/delete_operation.rb

Instance Attribute Summary

Attributes inherited from Operation

#ar

Instance Method Summary collapse

Methods inherited from Operation

#base_url, #check_response_errors, #entity_name, #initialize, #many_to_many_associated_table_name, #many_to_many_binding_name, #many_to_many_class_name, #many_to_many_entity_id, #many_to_many_entity_name, #many_to_many_foreign_key, #many_to_many_table?, #many_to_many_table_name, #many_to_many_use_old_api?, #old_base_url, #operation_headers, #operation_password, #operation_username, #run, #saved_many_to_many_id, #send_odata, #table_pluralize

Constructor Details

This class inherits a constructor from OData::Operation

Instance Method Details

#handle_operation_response(response) ⇒ Object



4
5
6
# File 'lib/odata/delete_operation.rb', line 4

def handle_operation_response(response)
  check_response_errors(response)
end

#operation_bodyObject



8
9
10
11
# File 'lib/odata/delete_operation.rb', line 8

def operation_body
  body = {}
  body.to_json
end

#operation_callback_nameObject



17
18
19
# File 'lib/odata/delete_operation.rb', line 17

def operation_callback_name
  :destroy
end

#operation_methodObject



13
14
15
# File 'lib/odata/delete_operation.rb', line 13

def operation_method
  :delete
end

#operation_urlObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/odata/delete_operation.rb', line 21

def operation_url
  # For many to many we disassociate
  if many_to_many_table?
    "#{old_base_url}#{many_to_many_associated_table_name(0)}Set(guid%27#{many_to_many_entity_id(0)}%27)/%24links/#{many_to_many_binding_name}(guid%27#{many_to_many_entity_id(1)}%27)"

    # Some reason I cant get the new api to delete, so just using old for now.
    # if many_to_many_use_old_api?
    #   "#{old_base_url}#{many_to_many_associated_table_name(0)}Set(guid%27#{many_to_many_entity_id(0)}%27)/%24links/#{many_to_many_binding_name}(guid%27#{many_to_many_entity_id(1)}%27)"
    # else
    #   "#{base_url}#{many_to_many_entity_name(0)}(#{many_to_many_entity_id(0)})/#{many_to_many_binding_name}/%24ref%3F%24id=#{base_url}#{many_to_many_entity_name(1)}(#{many_to_many_entity_id(1)})"
    # end
  else
    "#{base_url}#{entity_name}(#{@ar.id})"
  end
end