Module: ActionController::Routing

Defined in:
lib/action_controller/routing.rb

Overview

:nodoc:

Defined Under Namespace

Modules: NamedRoutes Classes: Component, ControllerComponent, DynamicComponent, PathComponent, Route, RouteSet, StaticComponent

Constant Summary collapse

Routes =
RouteSet.new

Class Method Summary collapse

Class Method Details

.controller_relative_to(controller, previous) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/action_controller/routing.rb', line 14

def controller_relative_to(controller, previous)
  if controller.nil?           then previous
  elsif controller[0] == ?/    then controller[1..-1]
  elsif %r{^(.*)/} =~ previous then "#{$1}/#{controller}"
  else controller
  end
end

.expiry_hash(options, recall) ⇒ Object



4
5
6
7
8
9
# File 'lib/action_controller/routing.rb', line 4

def expiry_hash(options, recall)
  k = v = nil
  expire_on = {}
  options.each {|k, v| expire_on[k] = ((rcv = recall[k]) && (rcv != v))}
  expire_on
end

.extract_parameter_value(parameter) ⇒ Object

:nodoc:



11
12
13
# File 'lib/action_controller/routing.rb', line 11

def extract_parameter_value(parameter) #:nodoc:
  CGI.escape((parameter.respond_to?(:to_param) ? parameter.to_param : parameter).to_s) 
end

.test_condition(expression, condition) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/action_controller/routing.rb', line 32

def test_condition(expression, condition)
  case condition
    when String then "(#{expression} == #{condition.inspect})"
    when Regexp then
      condition = Regexp.new("^#{condition.source}$") unless /^\^.*\$$/ =~ condition.source 
      "(#{condition.inspect} =~ #{expression})"
    when true then expression
    when nil then "! #{expression}"
    else
      raise ArgumentError, "Valid criteria are strings, regular expressions, true, or nil"
  end
end

.treat_hash(hash) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/action_controller/routing.rb', line 22

def treat_hash(hash)
  k = v = nil
  hash.each do |k, v|
    hash[k] = (v.respond_to? :to_param) ? v.to_param.to_s : v.to_s 
  end
  hash
end