Class: ActionController::Routing::PathSegment

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

Overview

:nodoc:

Defined Under Namespace

Classes: Result

Constant Summary collapse

EscapedSlash =
CGI.escape("/")

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, #extract_value, #extraction_code, #initialize, #local_name, #optionality_implied?, #string_structure, #to_s, #value_check, #value_regexp

Methods inherited from Segment

#all_optionals_available_condition, #continue_string_structure, #extraction_code, #initialize, #interpolation_statement, #optionality_implied?, #string_structure

Constructor Details

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

Instance Method Details

#defaultObject



763
764
765
# File 'lib/action_controller/routing.rb', line 763

def default
  ''
end

#default=(path) ⇒ Object

Raises:



767
768
769
# File 'lib/action_controller/routing.rb', line 767

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

#interpolation_chunkObject



759
760
761
# File 'lib/action_controller/routing.rb', line 759

def interpolation_chunk
  "\#{CGI.escape(#{local_name}.to_s).gsub(#{EscapedSlash.inspect}, '/')}"
end

#match_extraction(next_capture) ⇒ Object



771
772
773
# File 'lib/action_controller/routing.rb', line 771

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

#regexp_chunkObject



775
776
777
# File 'lib/action_controller/routing.rb', line 775

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