Class: ActionController::Routing::Route
- Defined in:
- lib/action_controller/routing.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#components ⇒ Object
Returns the value of attribute components.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#known ⇒ Object
Returns the value of attribute known.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #extra_keys(options) ⇒ Object
-
#initialize(path, options = {}) ⇒ Route
constructor
A new instance of Route.
- #initialize_keys ⇒ Object
- #inspect ⇒ Object
- #matches_controller?(controller) ⇒ Boolean
- #write_generation(generator = CodeGeneration::GenerationGenerator.new) ⇒ Object
- #write_recognition(generator = CodeGeneration::RecognitionGenerator.new) ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ Route
Returns a new instance of Route.
268 269 270 271 272 273 274 275 276 |
# File 'lib/action_controller/routing.rb', line 268 def initialize(path, = {}) @path, @options = path, initialize_components path defaults, conditions = initialize_hashes .dup @defaults = defaults.dup configure_components(defaults, conditions) initialize_keys end |
Instance Attribute Details
#components ⇒ Object
Returns the value of attribute components.
265 266 267 |
# File 'lib/action_controller/routing.rb', line 265 def components @components end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
266 267 268 |
# File 'lib/action_controller/routing.rb', line 266 def defaults @defaults end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
266 267 268 |
# File 'lib/action_controller/routing.rb', line 266 def keys @keys end |
#known ⇒ Object
Returns the value of attribute known.
265 266 267 |
# File 'lib/action_controller/routing.rb', line 265 def known @known end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
266 267 268 |
# File 'lib/action_controller/routing.rb', line 266 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
266 267 268 |
# File 'lib/action_controller/routing.rb', line 266 def path @path end |
Instance Method Details
#extra_keys(options) ⇒ Object
313 314 315 |
# File 'lib/action_controller/routing.rb', line 313 def extra_keys() .keys - @keys end |
#initialize_keys ⇒ Object
308 309 310 311 |
# File 'lib/action_controller/routing.rb', line 308 def initialize_keys @keys = (components.collect {|c| c.key} + known.keys).compact @keys.freeze end |
#inspect ⇒ Object
278 279 280 |
# File 'lib/action_controller/routing.rb', line 278 def inspect "<#{self.class} #{path.inspect}, #{.inspect[1..-1]}>" end |
#matches_controller?(controller) ⇒ Boolean
317 318 319 320 321 322 323 324 |
# File 'lib/action_controller/routing.rb', line 317 def matches_controller?(controller) if known[:controller] then known[:controller] == controller else c = components.find {|c| c.key == :controller} return false unless c return c.condition.nil? || eval(Routing.test_condition('controller', c.condition)) end end |
#write_generation(generator = CodeGeneration::GenerationGenerator.new) ⇒ Object
282 283 284 285 286 287 288 289 290 |
# File 'lib/action_controller/routing.rb', line 282 def write_generation(generator = CodeGeneration::GenerationGenerator.new) generator.before, generator.current, generator.after = [], components.first, (components[1..-1] || []) if known.empty? then generator.go else generator.if(generator.check_conditions(known)) {|gp| gp.go } end generator end |
#write_recognition(generator = CodeGeneration::RecognitionGenerator.new) ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/action_controller/routing.rb', line 292 def write_recognition(generator = CodeGeneration::RecognitionGenerator.new) g = generator.dup g.share_locals_with generator g.before, g.current, g.after = [], components.first, (components[1..-1] || []) known.each do |key, value| if key == :controller then ControllerComponent.assign_controller(g, value) else g.constant_result(key, value) end end g.go generator end |