diff options
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 |