diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-10-09 17:33:52 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-10-09 17:33:52 -0300 |
commit | 5c7e99257818c84ce4c70a34c2411cb671bcf995 (patch) | |
tree | b989d71c5910036f8fce99e9daebf3619a967a96 | |
parent | e33de7de4d5185459b491f8587a701d186873e36 (diff) | |
parent | ee47e34d82ec4d704c2db94e5f93e446077779b0 (diff) | |
download | rails-5c7e99257818c84ce4c70a34c2411cb671bcf995.tar.gz rails-5c7e99257818c84ce4c70a34c2411cb671bcf995.tar.bz2 rails-5c7e99257818c84ce4c70a34c2411cb671bcf995.zip |
Merge pull request #21927 from ronakjangir47/remove_is_a_spec
used predicate methods to avoid is_a? checks
-rw-r--r-- | actionpack/lib/action_dispatch/journey/nodes/node.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/journey/path/pattern.rb | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/journey/nodes/node.rb b/actionpack/lib/action_dispatch/journey/nodes/node.rb index d069bf0205..2793c5668d 100644 --- a/actionpack/lib/action_dispatch/journey/nodes/node.rb +++ b/actionpack/lib/action_dispatch/journey/nodes/node.rb @@ -42,6 +42,7 @@ module ActionDispatch def terminal?; false; end def star?; false; end def cat?; false; end + def group?; false; end end class Terminal < Node # :nodoc: @@ -95,6 +96,7 @@ module ActionDispatch class Group < Unary # :nodoc: def type; :GROUP; end + def group?; true; end end class Star < Unary # :nodoc: diff --git a/actionpack/lib/action_dispatch/journey/path/pattern.rb b/actionpack/lib/action_dispatch/journey/path/pattern.rb index e93970046c..5ee8810066 100644 --- a/actionpack/lib/action_dispatch/journey/path/pattern.rb +++ b/actionpack/lib/action_dispatch/journey/path/pattern.rb @@ -46,7 +46,7 @@ module ActionDispatch end def names - @names ||= spec.grep(Nodes::Symbol).map(&:name) + @names ||= spec.find_all(&:symbol?).map(&:name) end def required_names @@ -54,8 +54,8 @@ module ActionDispatch end def optional_names - @optional_names ||= spec.grep(Nodes::Group).flat_map { |group| - group.grep(Nodes::Symbol) + @optional_names ||= spec.find_all(&:group?).flat_map { |group| + group.find_all(&:symbol?) }.map(&:name).uniq end |