lib/action_controller/routing.rb

ActionController::Routing::Routes」はここでに定義されている。

279 class Route #:nodoc:
280 attr_accessor :components, :known
281 attr_reader :path, :options, :keys, :defaults

実際に「config/route.rb」で呼び出されているメソッドは以下の定義

568 def draw
569 old_routes = @routes
570 @routes = []
571
572 begin yield self
573 rescue
574 @routes = old_routes
575 raise
576 end
577 write_generation
578 write_recognition
579 end

こんな記述もあった。

585 # Defines a new named route with the provided name and arguments.
586 # This method need only be used when you wish to use a name that a RouteSet instance
587 # method exists for, such as categories.
588 #
589 # For example, map.categories '/categories', :controller => 'categories' will not work
590 # due to RouteSet#categories.


577、578行目で使用されているメソッドは以下のように定義されている。
nodocですが。)

71 class StaticComponent < Component #:nodoc:
72 attr_reader :value
73
74 def initialize(value)
75 @value = value
76 end
77
78 def write_recognition(g)
79 g.if_next_matches(value) do |gp|
80 gp.move_forward {|gpp| gpp.continue}
81 end
82 end
83
84 def write_generation(g)
85 g.add_segment(value) {|gp| gp.continue }
86 end
87 end

上記で使用されている「add_segment」は

lib/action_controller/code_generation.rb

で以下のように定義されてる。

200 def add_segment(*segments)
201 d = dup
202 d.segments.concat segments
203 yield d
204 end

「p = dup」は以下

64 def dup
65 copy = self.class.new(source)
66 self.class::FieldsToDuplicate.each do |sym|
67 value = self.send(sym)
68 value = value.dup unless value.nil? || value.is_a?(Numeric)
69 copy.send("#{sym}=", value)
70 end
71 return copy
72 end
73 end

「segments」は以下

171 def initialize(*args)
172 super(*args)
173 @after, @before = ,
174 @current = nil
175 @segments = []
176 end


うーん
とりあえず(個人的に)すっきりしました。
後日まとめよ。