Skip to content

Commit

Permalink
Further refactor build_conditions in route set
Browse files Browse the repository at this point in the history
Return the conditions from the keep_if call, and ignore the value
argument since it's not being used.
  • Loading branch information
carlosantoniodasilva committed Aug 11, 2012
1 parent a63fc94 commit ac7e170
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -409,21 +409,19 @@ def build_path(path, requirements, separators, anchor)
def build_conditions(current_conditions, path_values)
conditions = current_conditions.dup

verbs = conditions[:request_method] || []

# Rack-Mount requires that :request_method be a regular expression.
# :request_method represents the HTTP verb that matches this route.
#
# Here we munge values before they get sent on to rack-mount.
verbs = conditions[:request_method] || []
unless verbs.empty?
conditions[:request_method] = %r[^#{verbs.join('|')}$]
end
conditions.keep_if do |k,v|

conditions.keep_if do |k, _|
k == :action || k == :controller ||
@request_class.public_method_defined?(k) || path_values.include?(k)
end

conditions
end
private :build_conditions

Expand Down

0 comments on commit ac7e170

Please sign in to comment.