mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
used predicate methods to avoid is_a? checks
This commit is contained in:
parent
30bacc26f8
commit
ee47e34d82
2 changed files with 5 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue