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

RESERVED_PCHAR =
"#{Segment::RESERVED_PCHAR}/"
UNSAFE_PCHAR =
Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}]", false, 'N').freeze

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, #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



829
830
831
# File 'lib/action_controller/routing.rb', line 829

def default
  ''
end

#default=(path) ⇒ Object

Raises:



833
834
835
# File 'lib/action_controller/routing.rb', line 833

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

#interpolation_chunk(value_code = "#{local_name}") ⇒ Object



825
826
827
# File 'lib/action_controller/routing.rb', line 825

def interpolation_chunk(value_code = "#{local_name}")
  "\#{URI.escape(#{value_code}.to_s, ActionController::Routing::PathSegment::UNSAFE_PCHAR)}"
end

#match_extraction(next_capture) ⇒ Object



837
838
839
# File 'lib/action_controller/routing.rb', line 837

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)


845
846
847
# File 'lib/action_controller/routing.rb', line 845

def optionality_implied?
  true
end

#regexp_chunkObject



841
842
843
# File 'lib/action_controller/routing.rb', line 841

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