diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-29 15:23:30 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-29 15:23:30 -0700 |
commit | 15ffbedf3bb5907c3774fcc38466c799e92f9a04 (patch) | |
tree | 59017b2e215f23da792e7f460f9e77f533bd4832 /actionpack/lib/action_dispatch | |
parent | eabe504cdfa11b580c614d6bd501eb7cc60f485d (diff) | |
download | rails-15ffbedf3bb5907c3774fcc38466c799e92f9a04.tar.gz rails-15ffbedf3bb5907c3774fcc38466c799e92f9a04.tar.bz2 rails-15ffbedf3bb5907c3774fcc38466c799e92f9a04.zip |
add an alternate constructor to Strexp that takes a string
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/router/strexp.rb | 16 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/journey/router/strexp.rb b/actionpack/lib/action_dispatch/journey/router/strexp.rb index 161b41d6b2..29196d20bb 100644 --- a/actionpack/lib/action_dispatch/journey/router/strexp.rb +++ b/actionpack/lib/action_dispatch/journey/router/strexp.rb @@ -6,20 +6,22 @@ module ActionDispatch alias :compile :new end - attr_reader :path, :requirements, :separators, :anchor + attr_reader :path, :requirements, :separators, :anchor, :ast - def initialize(path, requirements, separators, anchor = true) + def self.build(path, requirements, separators, anchor = true) + parser = Journey::Parser.new + ast = parser.parse path + new ast, path, requirements, separators, anchor + end + + def initialize(ast, path, requirements, separators, anchor = true) + @ast = ast @path = path @requirements = requirements @separators = separators @anchor = anchor end - def ast - parser = Journey::Parser.new - parser.parse path - end - def names @path.scan(/:\w+/).map { |s| s.tr(':', '') } end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 3ca5abf0fd..66d1805702 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -427,7 +427,7 @@ module ActionDispatch end def build_path(path, requirements, separators, anchor) - strexp = Journey::Router::Strexp.new( + strexp = Journey::Router::Strexp.build( path, requirements, SEPARATORS, |