Permalink
Browse files

ask the strexp for the ast

  • Loading branch information...
1 parent 7da98d0 commit eabe504cdfa11b580c614d6bd501eb7cc60f485d @tenderlove tenderlove committed May 29, 2014
@@ -5,17 +5,16 @@ class Pattern # :nodoc:
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 @@ def initialize(path, requirements, separators, anchor = true)
@anchor = anchor
end
+ def ast
+ parser = Journey::Parser.new
+ parser.parse path
+ end
+
def names
@path.scan(/:\w+/).map { |s| s.tr(':', '') }
end

0 comments on commit eabe504

Please sign in to comment.