Class: ActionController::Routing::ControllerComponent
Overview
Instance Attribute Summary
#condition, #default
Class Method Summary
collapse
Instance Method Summary
collapse
#default_check, #dynamic?, #initialize, #optional?, #write_continue_generation, #write_dropout_generation, #write_generation, #write_recognition
Methods inherited from Component
#dynamic?, new, #optional?
Class Method Details
.assign_controller(g, controller) ⇒ Object
216
217
218
219
|
# File 'lib/action_controller/routing.rb', line 216
def assign_controller(g, controller)
expr = "::Controllers::#{controller.split('/').collect {|c| c.camelize}.join('::')}Controller"
g.result :controller, expr, true
end
|
.traverse_to_controller(segments, start_at = 0) ⇒ Object
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
# File 'lib/action_controller/routing.rb', line 221
def traverse_to_controller(segments, start_at = 0)
mod = ::Controllers
length = segments.length
index = start_at
mod_name = controller_name = segment = nil
while index < length
return nil unless /^[A-Za-z][A-Za-z\d_]*$/ =~ (segment = segments[index])
index += 1
mod_name = segment.camelize
controller_name = "#{mod_name}Controller"
return eval("mod::#{controller_name}", nil, 'routing.rb', __LINE__), (index - start_at) if mod.const_available?(controller_name)
return nil unless mod.const_available?(mod_name)
mod = eval("mod::#{mod_name}", nil, 'routing.rb', __LINE__)
end
end
|
Instance Method Details
#add_segments_to(g) ⇒ Object
187
188
189
|
# File 'lib/action_controller/routing.rb', line 187
def add_segments_to(g)
g.add_segment(%(\#{#{g.hash_value(key, true, default)}})) {|gp| yield gp}
end
|
#assign_result(g) {|g| ... } ⇒ Object
206
207
208
209
|
# File 'lib/action_controller/routing.rb', line 206
def assign_result(g)
g.result key, 'controller_value'
yield g
end
|
185
|
# File 'lib/action_controller/routing.rb', line 185
def key() :controller end
|
#recognition_check(g) ⇒ Object
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/action_controller/routing.rb', line 191
def recognition_check(g)
g << "controller_result = ::ActionController::Routing::ControllerComponent.traverse_to_controller(#{g.path_name}, #{g.index_name})"
g.if('controller_result') do |gp|
gp << 'controller_value, segments_to_controller = controller_result'
if condition
gp << "controller_path = #{gp.path_name}[#{gp.index_name},segments_to_controller].join('/')"
gp.if(Routing.test_condition("controller_path", condition)) do |gpp|
gpp.move_forward('segments_to_controller') {|gppp| yield gppp, :constraint}
end
else
gp.move_forward('segments_to_controller') {|gpp| yield gpp, :constraint}
end
end
end
|