diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG index cf7099b007fde276f8e33768a64a3809e61fe3b2..8ac17c24a1e93c458a533937cc8ee13997616785 100644 --- a/activeresource/CHANGELOG +++ b/activeresource/CHANGELOG @@ -1,3 +1,5 @@ *SVN* +* site= accepts URIs. [Jeremy Kemper] + * Initial checkin: object-oriented client for restful HTTP resources which follow the Rails convention. [DHH] diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 2d4025e5dd0bb4a48e4236bd12c05f4168f5f2d1..11064454d769d1525c34098e2b60018a389adb6a 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -4,9 +4,9 @@ module ActiveResource class Base class << self def site=(site) - @@site = URI.parse(site) + @@site = site.is_a?(URI) ? site : URI.parse(site) end - + def site @@site end @@ -96,4 +96,4 @@ def method_missing(method_symbol, *arguments) end end end -end \ No newline at end of file +end diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index 3c87ca532c46816fe58a9344c5296da007e80186..e4839613eee8de3902a86e4bb0a25131a4deed07 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -17,6 +17,18 @@ def setup ) end + + def test_site_accessor_accepts_uri_or_string_argument + site = URI.parse('http://localhost') + + assert_nothing_raised { Person.site = 'http://localhost' } + assert_equal site, Person.site + + assert_nothing_raised { Person.site = site } + assert_equal site, Person.site + end + + def test_collection_name assert_equal "people", Person.collection_name end @@ -57,4 +69,4 @@ def test_destroy assert Person.find(1).destroy assert_raises(ActiveResource::ClientError) { Person.find(2).destroy } end -end \ No newline at end of file +end