Class: ActionController::Routing::PathComponent

Inherits:
DynamicComponent show all
Defined in:
lib/action_controller/routing.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Result

Instance Attribute Summary

Attributes inherited from DynamicComponent

#key

Instance Method Summary collapse

Methods inherited from DynamicComponent

#add_segments_to, #assign_default, #assign_result, #default_check, #dynamic?, #initialize, #recognition_check, #write_continue_generation, #write_dropout_generation

Methods inherited from Component

#dynamic?, #key, new

Constructor Details

This class inherits a constructor from ActionController::Routing::DynamicComponent

Instance Method Details

#conditionObject



230
# File 'lib/action_controller/routing.rb', line 230

def condition() nil  end

#defaultObject



229
# File 'lib/action_controller/routing.rb', line 229

def default()   ''   end

#optional?Boolean

Returns:

  • (Boolean)


228
# File 'lib/action_controller/routing.rb', line 228

def optional?() true end

#write_generation(g) ⇒ Object

Raises:

  • (RoutingError)


232
233
234
235
236
237
238
239
# File 'lib/action_controller/routing.rb', line 232

def write_generation(g)
  raise RoutingError, 'Path components must occur last' unless g.after.empty?
  g.if("#{g.hash_value(key, true)} && ! #{g.hash_value(key, true)}.empty?") do
    g << "#{g.hash_value(key, true)} = #{g.hash_value(key, true)}.join('/') unless #{g.hash_value(key, true)}.is_a?(String)"
    g.add_segment("\#{CGI.escape_skipping_slashes(#{g.hash_value(key, true)})}") {|gp| gp.finish }
  end
  g.else { g.finish }
end

#write_recognition(g) ⇒ Object

Raises:

  • (RoutingError)


241
242
243
244
245
246
247
248
249
250
# File 'lib/action_controller/routing.rb', line 241

def write_recognition(g)
  raise RoutingError, "Path components must occur last" unless g.after.empty?
    
  start = g.index_name
  start = "(#{start})" unless /^\w+$/ =~ start
    
  value_expr = "#{g.path_name}[#{start}..-1] || []"
  g.result key, "ActionController::Routing::PathComponent::Result.new(#{value_expr})"
  g.finish(false)
end