diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-12-21 22:12:21 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-12-21 22:12:21 +0000 |
commit | e6988ef2ce31553c9c5f52a8d34899e39df67694 (patch) | |
tree | 88d64ef6f940fa3e8efe09e8ee0719dd2ff78da7 /activeresource/lib/active_resource | |
parent | 93c816f0c2ad45ef898de7c2dd2987f9ccb02678 (diff) | |
download | rails-e6988ef2ce31553c9c5f52a8d34899e39df67694.tar.gz rails-e6988ef2ce31553c9c5f52a8d34899e39df67694.tar.bz2 rails-e6988ef2ce31553c9c5f52a8d34899e39df67694.zip |
Subclasses share superclass site until explicitly set. This way you can set Superclass.site = ... after subclasses have been defined.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5767 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib/active_resource')
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index fd583d40e9..9a810e4adf 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -6,13 +6,14 @@ module ActiveResource # calls. cattr_accessor :logger - def self.inherited(base) - base.site = site.to_s if site - super - end - class << self - attr_reader :site + def site + if defined?(@site) + @site + elsif superclass != Object and superclass.site + superclass.site.dup.freeze + end + end def site=(site) @site = create_site_uri_from(site) @@ -83,13 +84,9 @@ module ActiveResource def find_single(scope, options) new(connection.get(element_path(scope, options)), options) end - + def create_site_uri_from(site) - returning site.is_a?(URI) ? site : URI.parse(site) do |uri| - def uri.<<(extra) - path << extra - end unless uri.respond_to?(:<<) - end + site.is_a?(URI) ? site.dup : URI.parse(site) end end |