Class: ActionController::Routing::ControllerSegment

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from DynamicSegment

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

#extract_valueObject

Make sure controller names like Admin/Content are correctly normalized to admin/content



744
745
746
# File 'lib/action_controller/routing.rb', line 744

def extract_value
  "#{local_name} = (hash[:#{key}] #{"|| #{default.inspect}" if default}).downcase"
end

#interpolation_chunkObject

Don’t CGI.escape the controller name, since it may have slashes in it, like admin/foo.



738
739
740
# File 'lib/action_controller/routing.rb', line 738

def interpolation_chunk
  "\#{#{local_name}.to_s}"
end

#match_extraction(next_capture) ⇒ Object



748
749
750
751
752
753
754
# File 'lib/action_controller/routing.rb', line 748

def match_extraction(next_capture)
  if default
    "params[:#{key}] = match[#{next_capture}] ? match[#{next_capture}].downcase : '#{default}'"
  else
    "params[:#{key}] = match[#{next_capture}].downcase if match[#{next_capture}]"
  end
end

#regexp_chunkObject



731
732
733
734
# File 'lib/action_controller/routing.rb', line 731

def regexp_chunk
  possible_names = Routing.possible_controllers.collect { |name| Regexp.escape name }
  "(?i-:(#{(regexp || Regexp.union(*possible_names)).source}))"
end