diff options
author | Ronak Jangir <ronakjangir47@gmail.com> | 2015-10-10 00:04:10 +0530 |
---|---|---|
committer | Ronak Jangir <ronakjangir47@gmail.com> | 2015-10-10 00:05:36 +0530 |
commit | ee47e34d82ec4d704c2db94e5f93e446077779b0 (patch) | |
tree | 0b6db0df3942a65cb40ef7135ccd4943e84d92b4 /actionpack | |
parent | 30bacc26f8f258b39e12f63fe52389a968d9c1ea (diff) | |
download | rails-ee47e34d82ec4d704c2db94e5f93e446077779b0.tar.gz rails-ee47e34d82ec4d704c2db94e5f93e446077779b0.tar.bz2 rails-ee47e34d82ec4d704c2db94e5f93e446077779b0.zip |
used predicate methods to avoid is_a? checks
Diffstat (limited to 'actionpack')
-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 |