diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-04-09 16:02:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-09 16:02:50 -0400 |
commit | 52114b7ae667d39a2ace7ded746b067feb1f732e (patch) | |
tree | 1aa51d63960674234f67cd85cbfb42dcd603c880 /actionpack/lib | |
parent | d5f2deb1539927c8793588e7d1e86d84211d4da8 (diff) | |
parent | 79c15566da3f267d66cfd6cc8e2257b6aacc0e38 (diff) | |
download | rails-52114b7ae667d39a2ace7ded746b067feb1f732e.tar.gz rails-52114b7ae667d39a2ace7ded746b067feb1f732e.tar.bz2 rails-52114b7ae667d39a2ace7ded746b067feb1f732e.zip |
Merge pull request #35913 from baweaver/baweaver/actionpack/named_captures
Adds named_captures to MatchData to emulate Regex
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/path/pattern.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/journey/path/pattern.rb b/actionpack/lib/action_dispatch/journey/path/pattern.rb index 697f5b9d8b..a968df5f19 100644 --- a/actionpack/lib/action_dispatch/journey/path/pattern.rb +++ b/actionpack/lib/action_dispatch/journey/path/pattern.rb @@ -136,6 +136,10 @@ module ActionDispatch Array.new(length - 1) { |i| self[i + 1] } end + def named_captures + @names.zip(captures).to_h + end + def [](x) idx = @offsets[x - 1] + x @match[idx] |