Class: Mack::Routes::RouteMap::Route
- Inherits:
-
Object
- Object
- Mack::Routes::RouteMap::Route
- Defined in:
- lib/routing/route_map.rb
Overview
regex_from_pattern
Instance Attribute Summary collapse
-
#embedded_parameters ⇒ Object
Returns the value of attribute embedded_parameters.
-
#method ⇒ Object
Returns the value of attribute method.
-
#options ⇒ Object
Returns the value of attribute options.
-
#original_pattern ⇒ Object
Returns the value of attribute original_pattern.
-
#regex_pattern ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(original_pattern, regex_pattern, method, options) ⇒ Route
constructor
A new instance of Route.
- #options_with_embedded_parameters(uri) ⇒ Object
Constructor Details
#initialize(original_pattern, regex_pattern, method, options) ⇒ Route
Returns a new instance of Route.
261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/routing/route_map.rb', line 261 def initialize(original_pattern, regex_pattern, method, ) self.original_pattern = original_pattern self.regex_pattern = regex_pattern self.method = method self. = self. = [] # find out where the embedded_parameters are: original_pattern.split("/").each_with_index do |seg, ind| if seg.match(/^:/) self.[ind] = seg[1..seg.length].to_sym end end end |
Instance Attribute Details
#embedded_parameters ⇒ Object
Returns the value of attribute embedded_parameters.
259 260 261 |
# File 'lib/routing/route_map.rb', line 259 def @embedded_parameters end |
#method ⇒ Object
Returns the value of attribute method.
256 257 258 |
# File 'lib/routing/route_map.rb', line 256 def method @method end |
#options ⇒ Object
Returns the value of attribute options.
258 259 260 |
# File 'lib/routing/route_map.rb', line 258 def @options end |
#original_pattern ⇒ Object
Returns the value of attribute original_pattern.
257 258 259 |
# File 'lib/routing/route_map.rb', line 257 def original_pattern @original_pattern end |
#regex_pattern ⇒ Object
:nodoc:
255 256 257 |
# File 'lib/routing/route_map.rb', line 255 def regex_pattern @regex_pattern end |
Instance Method Details
#options_with_embedded_parameters(uri) ⇒ Object
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/routing/route_map.rb', line 275 def (uri) opts = {:format => :html}.merge(self.) m = uri.match(/\..+$/) if m m = m.to_s opts[:format]= m[1..m.size].to_sym uri.gsub!(/\..+$/, "") end split_uri = uri.split("/") self..each_with_index do |val, ind| unless val.nil? opts[val] = split_uri[ind] end end opts end |