Class: ActionController::Routing::PathSegment

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

Overview

:nodoc:

Defined Under Namespace

Classes: Result

Constant Summary

Constants inherited from Segment

Segment::RESERVED_PCHAR, Segment::SAFE_PCHAR, Segment::UNSAFE_PCHAR

Instance Attribute Summary

Attributes inherited from DynamicSegment

#key, #regexp

Attributes inherited from Segment

#is_optional

Instance Method Summary collapse

Methods inherited from DynamicSegment

#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

Constructor Details

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

Instance Method Details

#defaultObject



276
277
278
# File 'lib/action_controller/routing/segments.rb', line 276

def default
  ''
end

#default=(path) ⇒ Object

Raises:



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_chunkObject



288
289
290
# File 'lib/action_controller/routing/segments.rb', line 288

def default_regexp_chunk
  "(.*)"
end

#extract_valueObject



272
273
274
# File 'lib/action_controller/routing/segments.rb', line 272

def extract_value
  "#{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

#match_extraction(next_capture) ⇒ Object



284
285
286
# File 'lib/action_controller/routing/segments.rb', line 284

def match_extraction(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_capturesObject



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

Returns:

  • (Boolean)


296
297
298
# File 'lib/action_controller/routing/segments.rb', line 296

def optionality_implied?
  true
end