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_has_modifiers?, #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
280
281
282
|
# File 'lib/action_controller/routing/segments.rb', line 280
def default
''
end
|
#default=(path) ⇒ Object
284
285
286
|
# File 'lib/action_controller/routing/segments.rb', line 284
def default=(path)
raise RoutingError, "paths cannot have non-empty default values" unless path.blank?
end
|
276
277
278
|
# File 'lib/action_controller/routing/segments.rb', line 276
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
272
273
274
|
# File 'lib/action_controller/routing/segments.rb', line 272
def interpolation_chunk(value_code = local_name)
"\#{#{value_code}}"
end
|
288
289
290
|
# File 'lib/action_controller/routing/segments.rb', line 288
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
296
297
298
|
# File 'lib/action_controller/routing/segments.rb', line 296
def number_of_captures
regexp ? regexp.number_of_captures : 1
end
|
#optionality_implied? ⇒ Boolean
300
301
302
|
# File 'lib/action_controller/routing/segments.rb', line 300
def optionality_implied?
true
end
|
#regexp_chunk ⇒ Object
292
293
294
|
# File 'lib/action_controller/routing/segments.rb', line 292
def regexp_chunk
regexp || "(.*)"
end
|