Parent

Class/Module Index [+]

Quicksearch

ActionController::Routing::OptionalFormatSegment

The OptionalFormatSegment allows for any resource route to have an optional :format, which decreases the amount of routes created by 50%.

Public Class Methods

new(key = nil, options = {}) click to toggle source
# File lib/action_controller/routing/segments.rb, line 312
def initialize(key = nil, options = {})
  super(:format, {:optional => true}.merge(options))            
end

Public Instance Methods

extract_value() click to toggle source
# File lib/action_controller/routing/segments.rb, line 328
def extract_value
  "#{local_name} = options[:#{key}] && options[:#{key}].to_s.downcase"
end
interpolation_chunk() click to toggle source
# File lib/action_controller/routing/segments.rb, line 316
def interpolation_chunk
  "." + super
end
match_extraction(next_capture) click to toggle source

the value should not include the period (.)

# File lib/action_controller/routing/segments.rb, line 333
def match_extraction(next_capture)
  %[
    if (m = match[#{next_capture}])
      params[:#{key}] = URI.unescape(m.from(1))
    end
  ]
end
regexp_chunk() click to toggle source
# File lib/action_controller/routing/segments.rb, line 320
def regexp_chunk
  '/|(\.[^/?\.]+)?'
end
to_s() click to toggle source
# File lib/action_controller/routing/segments.rb, line 324
def to_s
  '(.:format)?'
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.