aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/custom_methods.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activeresource/lib/active_resource/custom_methods.rb')
-rw-r--r--activeresource/lib/active_resource/custom_methods.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/activeresource/lib/active_resource/custom_methods.rb b/activeresource/lib/active_resource/custom_methods.rb
index a8857b8461..e08c664307 100644
--- a/activeresource/lib/active_resource/custom_methods.rb
+++ b/activeresource/lib/active_resource/custom_methods.rb
@@ -33,23 +33,24 @@ module ActiveResource
module CustomMethods
def self.included(within)
within.class_eval do
+ extend ActiveResource::CustomMethods::ClassMethods
+ include ActiveResource::CustomMethods::InstanceMethods
+
class << self
- include ActiveResource::CustomMethods::ClassMethods
-
alias :orig_delete :delete
-
+
def get(method_name, options = {})
connection.get(custom_method_collection_url(method_name, options), headers)
end
-
+
def post(method_name, options = {}, body = '')
connection.post(custom_method_collection_url(method_name, options), body, headers)
end
-
+
def put(method_name, options = {}, body = '')
connection.put(custom_method_collection_url(method_name, options), body, headers)
end
-
+
# Need to jump through some hoops to retain the original class 'delete' method
def delete(custom_method_name, options = {})
if (custom_method_name.is_a?(Symbol))
@@ -59,12 +60,9 @@ module ActiveResource
end
end
end
-
end
-
- within.send(:include, ActiveResource::CustomMethods::InstanceMethods)
end
-
+
module ClassMethods
def custom_method_collection_url(method_name, options = {})
prefix_options, query_options = split_options(options)
@@ -96,12 +94,12 @@ module ActiveResource
private
def custom_method_element_url(method_name, options = {})
- "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.xml#{self.class.send(:query_string, options)}"
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{id}/#{method_name}.xml#{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}.xml#{self.class.send(:query_string, options)}"
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/new/#{method_name}.xml#{self.class.send!(:query_string, options)}"
end
end
end
-end \ No newline at end of file
+end