Permalink
Browse files

- refactoring, move prefix_options check to a custom method

  • Loading branch information...
1 parent a71e07d commit 30fb3638cce6fd27d003c7e0c4f689a0f1e28177 @gramos gramos committed Sep 13, 2010
Showing with 9 additions and 5 deletions.
  1. +9 −5 activeresource/lib/active_resource/base.rb
View
14 activeresource/lib/active_resource/base.rb
@@ -621,11 +621,7 @@ def prefix(options={}) "#{prefix_call}" end
# # => /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
+ check_prefix_options(prefix_options)
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)}"
@@ -848,6 +844,14 @@ def exists?(id, options = {})
end
private
+
+ def check_prefix_options(prefix_options)
+ p_options = HashWithIndifferentAccess.new(prefix_options)
+ prefix_parameters.each do |p|
+ raise(MissingPrefixParam, "#{p} prefix_option is missing") if p_options[p].blank?
+ end
+ end
+
# Find every resource
def find_every(options)
begin

0 comments on commit 30fb363

Please sign in to comment.