diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-04 18:42:20 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-04 18:42:20 -0300 |
commit | 95ab4fd6b7cfd1f65c68e773377cc79e777f50fc (patch) | |
tree | a59e88de788666cebdff445e6b4a30199f2ee88f /actionpack/lib/action_dispatch | |
parent | d65ab433ae095d99b51786c5c69be8f6cdd5e249 (diff) | |
parent | 9fd0c605b9bcfb2c2e854f3120bd3625eaa017f5 (diff) | |
download | rails-95ab4fd6b7cfd1f65c68e773377cc79e777f50fc.tar.gz rails-95ab4fd6b7cfd1f65c68e773377cc79e777f50fc.tar.bz2 rails-95ab4fd6b7cfd1f65c68e773377cc79e777f50fc.zip |
Merge pull request #11166 from xavier/callable_constraint_verification
Callable route constraint verification
Conflicts:
actionpack/CHANGELOG.md
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 400956adee..6c4c7c8d80 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -159,6 +159,8 @@ module ActionDispatch @defaults[key] ||= default end end + elsif options[:constraints] + verify_callable_constraint(options[:constraints]) end if Regexp === options[:format] @@ -168,6 +170,11 @@ module ActionDispatch end end + def verify_callable_constraint(callable_constraint) + return if callable_constraint.respond_to?(:call) || callable_constraint.respond_to?(:matches?) + raise ArgumentError, "Invalid constraint: #{callable_constraint.inspect} must respond to :call or :matches?" + end + def normalize_conditions! @conditions[:path_info] = path |