mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:01 -05:00
fix deprecation warnings in activeresource
This commit is contained in:
@@ -1477,7 +1477,7 @@ module ActiveResource
|
||||
extend ActiveModel::Naming
|
||||
include CustomMethods, Observing, Validations
|
||||
include ActiveModel::Conversion
|
||||
include ActiveModel::Serializers::JSON
|
||||
include ActiveModel::Serializers::Xml
|
||||
include ActiveModel::Serializable::JSON
|
||||
include ActiveModel::Serializable::XML
|
||||
end
|
||||
end
|
||||
|
||||
@@ -85,37 +85,35 @@ module ActiveResource
|
||||
end
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
def get(method_name, options = {})
|
||||
self.class.format.decode(connection.get(custom_method_element_url(method_name, options), self.class.headers).body)
|
||||
end
|
||||
|
||||
def post(method_name, options = {}, body = nil)
|
||||
request_body = body.blank? ? encode : body
|
||||
if new?
|
||||
connection.post(custom_method_new_element_url(method_name, options), request_body, self.class.headers)
|
||||
else
|
||||
connection.post(custom_method_element_url(method_name, options), request_body, self.class.headers)
|
||||
end
|
||||
end
|
||||
|
||||
def put(method_name, options = {}, body = '')
|
||||
connection.put(custom_method_element_url(method_name, options), body, self.class.headers)
|
||||
end
|
||||
|
||||
def delete(method_name, options = {})
|
||||
connection.delete(custom_method_element_url(method_name, options), self.class.headers)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def custom_method_element_url(method_name, options = {})
|
||||
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}"
|
||||
end
|
||||
|
||||
def custom_method_new_element_url(method_name, options = {})
|
||||
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}"
|
||||
end
|
||||
def get(method_name, options = {})
|
||||
self.class.format.decode(connection.get(custom_method_element_url(method_name, options), self.class.headers).body)
|
||||
end
|
||||
|
||||
def post(method_name, options = {}, body = nil)
|
||||
request_body = body.blank? ? encode : body
|
||||
if new?
|
||||
connection.post(custom_method_new_element_url(method_name, options), request_body, self.class.headers)
|
||||
else
|
||||
connection.post(custom_method_element_url(method_name, options), request_body, self.class.headers)
|
||||
end
|
||||
end
|
||||
|
||||
def put(method_name, options = {}, body = '')
|
||||
connection.put(custom_method_element_url(method_name, options), body, self.class.headers)
|
||||
end
|
||||
|
||||
def delete(method_name, options = {})
|
||||
connection.delete(custom_method_element_url(method_name, options), self.class.headers)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def custom_method_element_url(method_name, options = {})
|
||||
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}"
|
||||
end
|
||||
|
||||
def custom_method_new_element_url(method_name, options = {})
|
||||
"#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.#{self.class.format.extension}#{self.class.__send__(:query_string, options)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user