Class: RoadForest::Dispatcher::Route
- Inherits:
-
Webmachine::Dispatcher::Route
- Object
- Webmachine::Dispatcher::Route
- RoadForest::Dispatcher::Route
- Defined in:
- lib/roadforest/application/dispatcher.rb
Instance Method Summary collapse
- #build_params(vars = nil) ⇒ Object
-
#build_path(vars = nil) ⇒ String
Create a complete URL for this route, doing any necessary variable substitution.
Instance Method Details
#build_params(vars = nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/roadforest/application/dispatcher.rb', line 79 def build_params(vars = nil) vars ||= {} params = Application::Parameters.new path_set = Hash[path_spec.find_all{|segment| segment.is_a? Symbol}.map{|seg| [seg, true]}] vars.to_hash.each do |key, value| if(path_set.has_key?(key)) params.path_info[key] = value elsif(key == '*') params.path_tokens = value else params.query_params[key] = value end end params end |
#build_path(vars = nil) ⇒ String
Create a complete URL for this route, doing any necessary variable substitution.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/roadforest/application/dispatcher.rb', line 67 def build_path(vars = nil) vars ||= {} "/" + path_spec.map do |segment| case segment when '*',Symbol vars.fetch(segment) when String segment end end.join("/") end |