aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource
diff options
context:
space:
mode:
authorGaston Ramos <ramos.gaston@gmail.com>2010-09-13 17:05:52 -0300
committerGaston Ramos <ramos.gaston@gmail.com>2010-09-27 15:25:16 -0300
commita71e07d61e8bb69788b7120a5cf0d3620c6094be (patch)
tree2e1b6900b9f38e32b48582b88c285e5fa88fa6da /activeresource/lib/active_resource
parente3d6434dd9ef052ce703b36f968eb9f6fe1f0a11 (diff)
downloadrails-a71e07d61e8bb69788b7120a5cf0d3620c6094be.tar.gz
rails-a71e07d61e8bb69788b7120a5cf0d3620c6094be.tar.bz2
rails-a71e07d61e8bb69788b7120a5cf0d3620c6094be.zip
- elmenth_path raise an ActiveResource::MissingPrefixParam exception when prefix_options does not has all required prefix_options ex: class StreetAddress < ActiveResource::Base self.site = "http://37s.sunrise.i:3000/people/:person_id/" end
StreetAddress.element_path(1) # => ActiveResource::MissingPrefixParam
Diffstat (limited to 'activeresource/lib/active_resource')
-rw-r--r--activeresource/lib/active_resource/base.rb6
-rw-r--r--activeresource/lib/active_resource/exceptions.rb3
2 files changed, 9 insertions, 0 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index d31db9f0ba..80af7e7adf 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -621,6 +621,12 @@ module ActiveResource
# # => /posts/5/comments/1.xml?active=1
#
def element_path(id, prefix_options = {}, query_options = nil)
+
+ p_options = HashWithIndifferentAccess.new(prefix_options)
+ prefix_parameters.each do |p|
+ raise MissingPrefixParam if p_options[p].blank?
+ end
+
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}"
end
diff --git a/activeresource/lib/active_resource/exceptions.rb b/activeresource/lib/active_resource/exceptions.rb
index 0f4549fd73..6b953b28ad 100644
--- a/activeresource/lib/active_resource/exceptions.rb
+++ b/activeresource/lib/active_resource/exceptions.rb
@@ -36,6 +36,9 @@ module ActiveResource
def to_s; response['Location'] ? "#{super} => #{response['Location']}" : super; end
end
+ # Raised when ...
+ class MissingPrefixParam < ArgumentError; end # :nodoc:
+
# 4xx Client Error
class ClientError < ConnectionError; end # :nodoc: