Class: ActionController::Routing::PathSegment
Overview
Defined Under Namespace
Classes: Result
Constant Summary
Constants inherited
from Segment
Segment::RESERVED_PCHAR, Segment::SAFE_PCHAR, Segment::UNSAFE_PCHAR
Instance Attribute Summary
#key, #regexp
Attributes inherited from Segment
#is_optional
Instance Method Summary
collapse
#build_pattern, #expiry_statement, #extraction_code, #initialize, #local_name, #regexp_chunk, #regexp_has_modifiers?, #regexp_string, #string_structure, #to_s, #value_check, #value_regexp
Methods inherited from Segment
#all_optionals_available_condition, #continue_string_structure, #extraction_code, #initialize, #interpolation_statement, #string_structure
Instance Method Details
276
277
278
|
# File 'lib/action_controller/routing/segments.rb', line 276
def default
''
end
|
#default=(path) ⇒ Object
280
281
282
|
# File 'lib/action_controller/routing/segments.rb', line 280
def default=(path)
raise RoutingError, "paths cannot have non-empty default values" unless path.blank?
end
|
#default_regexp_chunk ⇒ Object
288
289
290
|
# File 'lib/action_controller/routing/segments.rb', line 288
def default_regexp_chunk
"(.*)"
end
|
272
273
274
|
# File 'lib/action_controller/routing/segments.rb', line 272
def
"#{local_name} = hash[:#{key}] && Array(hash[:#{key}]).collect { |path_component| URI.escape(path_component.to_param, ActionController::Routing::Segment::UNSAFE_PCHAR) }.to_param #{"|| #{default.inspect}" if default}"
end
|
#interpolation_chunk(value_code = local_name) ⇒ Object
268
269
270
|
# File 'lib/action_controller/routing/segments.rb', line 268
def interpolation_chunk(value_code = local_name)
"\#{#{value_code}}"
end
|
284
285
286
|
# File 'lib/action_controller/routing/segments.rb', line 284
def (next_capture)
"params[:#{key}] = PathSegment::Result.new_escaped((match[#{next_capture}]#{" || " + default.inspect if default}).split('/'))#{" if match[" + next_capture + "]" if !default}"
end
|
#number_of_captures ⇒ Object
292
293
294
|
# File 'lib/action_controller/routing/segments.rb', line 292
def number_of_captures
regexp ? regexp.number_of_captures : 1
end
|
#optionality_implied? ⇒ Boolean
296
297
298
|
# File 'lib/action_controller/routing/segments.rb', line 296
def optionality_implied?
true
end
|