aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2007-06-27 16:00:07 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2007-06-27 16:00:07 +0000
commit80d539bd4daa180e0c792b3878b2250c9913c437 (patch)
tree5ac65d2512d5221fb565126a6caaf9a50a5cc579 /activeresource/lib/active_resource
parent868e6b08df4b16fb71cc8a66308174253ff67bdb (diff)
downloadrails-80d539bd4daa180e0c792b3878b2250c9913c437.tar.gz
rails-80d539bd4daa180e0c792b3878b2250c9913c437.tar.bz2
rails-80d539bd4daa180e0c792b3878b2250c9913c437.zip
Fixes that using a subclass of an ARes object would cache a connection object based of its parent's site variable. Changing the parent's site would have no effect on the descentent objects.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7143 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib/active_resource')
-rw-r--r--activeresource/lib/active_resource/base.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 0255eefc55..d33195e261 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -164,15 +164,19 @@ module ActiveResource
# The site variable is required ActiveResource's mapping to work.
def site=(site)
@connection = nil
- @site = create_site_uri_from(site)
+ @site = site.nil? ? nil : create_site_uri_from(site)
end
# An instance of ActiveResource::Connection that is the base connection to the remote service.
# The +refresh+ parameter toggles whether or not the connection is refreshed at every request
# or not (defaults to +false+).
def connection(refresh = false)
- @connection = Connection.new(site) if refresh || @connection.nil?
- @connection
+ if defined?(@connection) or superclass == Object
+ @connection = Connection.new(site) if refresh || @connection.nil?
+ @connection
+ else
+ superclass.connection
+ end
end
def headers