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::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_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

Constructor Details

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

Instance Method Details

#defaultObject



255
256
257
# File 'lib/action_controller/routing/segments.rb', line 255

def default
  ''
end

#default=(path) ⇒ Object

Raises:



259
260
261
# File 'lib/action_controller/routing/segments.rb', line 259

def default=(path)
  raise RoutingError, "paths cannot have non-empty default values" unless path.blank?
end

#extract_valueObject



251
252
253
# File 'lib/action_controller/routing/segments.rb', line 251

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



247
248
249
# File 'lib/action_controller/routing/segments.rb', line 247

def interpolation_chunk(value_code = "#{local_name}")
  "\#{#{value_code}}"
end

#match_extraction(next_capture) ⇒ Object



263
264
265
# File 'lib/action_controller/routing/segments.rb', line 263

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

#optionality_implied?Boolean

Returns:

  • (Boolean)


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

def optionality_implied?
  true
end

#regexp_chunkObject



267
268
269
# File 'lib/action_controller/routing/segments.rb', line 267

def regexp_chunk
  regexp || "(.*)"
end