mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ask the strexp for the ast
This commit is contained in:
parent
7da98d0a59
commit
eabe504cdf
2 changed files with 7 additions and 3 deletions
|
@ -5,17 +5,16 @@ module ActionDispatch
|
|||
attr_reader :spec, :requirements, :anchored
|
||||
|
||||
def initialize(strexp)
|
||||
parser = Journey::Parser.new
|
||||
|
||||
@anchored = true
|
||||
|
||||
case strexp
|
||||
when String
|
||||
parser = Journey::Parser.new
|
||||
@spec = parser.parse(strexp)
|
||||
@requirements = {}
|
||||
@separators = "/.?"
|
||||
when Router::Strexp
|
||||
@spec = parser.parse(strexp.path)
|
||||
@spec = strexp.ast
|
||||
@requirements = strexp.requirements
|
||||
@separators = strexp.separators.join
|
||||
@anchored = strexp.anchor
|
||||
|
|
|
@ -15,6 +15,11 @@ module ActionDispatch
|
|||
@anchor = anchor
|
||||
end
|
||||
|
||||
def ast
|
||||
parser = Journey::Parser.new
|
||||
parser.parse path
|
||||
end
|
||||
|
||||
def names
|
||||
@path.scan(/:\w+/).map { |s| s.tr(':', '') }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue