Class: ActionController::Routing::Route
- Inherits:
-
Object
- Object
- 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.
341 342 343 344 345 346 347 348 349 350 |
# File 'lib/action_controller/routing.rb', line 341 def initialize(path, = {}) @path, @options = path, initialize_components path defaults, conditions = initialize_hashes .dup @defaults = defaults.dup configure_components(defaults, conditions) add_default_requirements initialize_keys end |
Instance Attribute Details
#components ⇒ Object
Returns the value of attribute components.
338 339 340 |
# File 'lib/action_controller/routing.rb', line 338 def components @components end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
339 340 341 |
# File 'lib/action_controller/routing.rb', line 339 def defaults @defaults end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
339 340 341 |
# File 'lib/action_controller/routing.rb', line 339 def keys @keys end |
#known ⇒ Object
Returns the value of attribute known.
338 339 340 |
# File 'lib/action_controller/routing.rb', line 338 def known @known end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
339 340 341 |
# File 'lib/action_controller/routing.rb', line 339 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
339 340 341 |
# File 'lib/action_controller/routing.rb', line 339 def path @path end |
Instance Method Details
#extra_keys(options) ⇒ Object
394 395 396 |
# File 'lib/action_controller/routing.rb', line 394 def extra_keys() .keys - @keys end |
#initialize_keys ⇒ Object
389 390 391 392 |
# File 'lib/action_controller/routing.rb', line 389 def initialize_keys @keys = (components.collect {|c| c.key} + known.keys).compact @keys.freeze end |
#inspect ⇒ Object
352 353 354 |
# File 'lib/action_controller/routing.rb', line 352 def inspect "<#{self.class} #{path.inspect}, #{.inspect[1..-1]}>" end |
#matches_controller?(controller) ⇒ Boolean
398 399 400 401 402 403 404 405 |
# File 'lib/action_controller/routing.rb', line 398 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
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/action_controller/routing.rb', line 356 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 # Alter the conditions to allow :action => 'index' to also catch :action => nil altered_known = known.collect do |k, v| if k == :action && v== 'index' then [k, [nil, 'index']] else [k, v] end end generator.if(generator.check_conditions(altered_known)) {|gp| gp.go } end generator end |
#write_recognition(generator = CodeGeneration::RecognitionGenerator.new) ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/action_controller/routing.rb', line 373 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 |