diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-12-13 02:15:27 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-12-13 02:15:27 +0000 |
commit | 011f4e7413f1bde83aa62a5fc46afd6957ff9b3e (patch) | |
tree | 3d7a2bc5998994c6ba2ee1759914dac15254beef /activeresource/lib | |
parent | 2f184c338b6379baecde8c882f72c4fa806a3a0b (diff) | |
download | rails-011f4e7413f1bde83aa62a5fc46afd6957ff9b3e.tar.gz rails-011f4e7413f1bde83aa62a5fc46afd6957ff9b3e.tar.bz2 rails-011f4e7413f1bde83aa62a5fc46afd6957ff9b3e.zip |
Allow subclassed resources to share the site info [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5717 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib')
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 5f3820b2be..fd583d40e9 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -6,11 +6,16 @@ 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=(site) - @site = site.is_a?(URI) ? site : URI.parse(site) + @site = create_site_uri_from(site) @connection = nil @site end @@ -78,6 +83,14 @@ 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 + end end attr_accessor :attributes |