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



761
762
763
# File 'lib/action_controller/routing.rb', line 761

def default
  ''
end

#default=(path) ⇒ Object

Raises:



765
766
767
# File 'lib/action_controller/routing.rb', line 765

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

#interpolation_chunkObject



757
758
759
# File 'lib/action_controller/routing.rb', line 757

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

#match_extraction(next_capture) ⇒ Object



769
770
771
# File 'lib/action_controller/routing.rb', line 769

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



773
774
775
# File 'lib/action_controller/routing.rb', line 773

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