class RoutingFilter::Locale

Attributes

exclude[R]

Public Class Methods

include_default_locale?() click to toggle source
# File lib/routing_filter/filters/locale.rb, line 29
def include_default_locale?
  @@include_default_locale
end
locales() click to toggle source
# File lib/routing_filter/filters/locale.rb, line 33
def locales
  @@locales ||= I18n.available_locales.map(&:to_sym)
end
locales=(locales) click to toggle source
# File lib/routing_filter/filters/locale.rb, line 37
def locales=(locales)
  @@locales = locales.map(&:to_sym)
end
locales_pattern() click to toggle source
# File lib/routing_filter/filters/locale.rb, line 41
def locales_pattern
  @@locales_pattern ||= %r(^/(#{self.locales.map { |l| Regexp.escape(l.to_s) }.join('|')})(?=/|$))
end
new(*args) click to toggle source
Calls superclass method RoutingFilter::Filter::new
# File lib/routing_filter/filters/locale.rb, line 48
def initialize(*args)
  super
  @exclude = options[:exclude]
end

Public Instance Methods

around_recognize(path, env) { || ... } click to toggle source
# File lib/routing_filter/filters/locale.rb, line 54
def around_recognize(path, env, &block)
  locale = extract_segment!(self.class.locales_pattern, path) # remove the locale from the beginning of the path
  yield.tap do |params|                                       # invoke the given block (calls more filters and finally routing)
    params[:locale] = locale if locale                        # set recognized locale to the resulting params hash
  end