From 7370e54cc4d6b298a29383bf943b277bcfb730aa Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 5 Dec 2006 19:12:51 +0000 Subject: *_path instance methods. Check for missing/invalid site uri. http_mock response takes message arg, extracts numeric code. Tests log to test/debug.log git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5680 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activeresource/lib/active_resource/base.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'activeresource/lib/active_resource/base.rb') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 5d72d98be6..07933d499b 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -106,7 +106,7 @@ module ActiveResource end def destroy - connection.delete(self.class.element_path(id, prefix_options)) + connection.delete(element_path) end def to_xml(options={}) @@ -155,12 +155,12 @@ module ActiveResource end def update - connection.put(self.class.element_path(id, prefix_options), to_xml) + connection.put(element_path, to_xml) true end def create - resp = connection.post(self.class.collection_path(prefix_options), to_xml) + resp = connection.post(collection_path, to_xml) self.id = id_from_response(resp) true end @@ -170,6 +170,14 @@ module ActiveResource response['Location'][/\/([^\/]*?)(\.\w+)?$/, 1] end + def element_path(options = nil) + self.class.element_path(id, options || prefix_options) + end + + def collection_path(options = nil) + self.class.collection_path(options || prefix_options) + end + private def find_or_create_resource_for_collection(name) find_or_create_resource_for(name.to_s.singularize) -- cgit v1.2.3