Module: I18nRouting::JourneyRoute
- Defined in:
- lib/i18n_routing_rails32.rb
Overview
Journey::Route module Exists in order to use appropriate localized route when using url_for
Class Method Summary collapse
-
.included(mod) ⇒ Object
Alias methods in order to handle i18n routes.
Instance Method Summary collapse
-
#format_with_i18n_routing(path_options) ⇒ Object
Called for dynamic route generation If a @locale is present and if this locale is not the current one => return nil and refuse to generate the route.
-
#initialize_with_i18n_routing(name, app, path, constraints, defaults = {}) ⇒ Object
During route initialization, if a condition i18n_locale is present Delete it, store it in @locale, and add it to @defaults.
Class Method Details
.included(mod) ⇒ Object
Alias methods in order to handle i18n routes
391 392 393 394 |
# File 'lib/i18n_routing_rails32.rb', line 391 def self.included(mod) mod.send :alias_method_chain, :format, :i18n_routing mod.send :alias_method_chain, :initialize, :i18n_routing end |
Instance Method Details
#format_with_i18n_routing(path_options) ⇒ Object
Called for dynamic route generation If a @locale is present and if this locale is not the current one
=> return nil and refuse to generate the route
412 413 414 415 |
# File 'lib/i18n_routing_rails32.rb', line 412 def format_with_i18n_routing() return nil if @locale and @locale != I18n.locale.to_sym format_without_i18n_routing() end |
#initialize_with_i18n_routing(name, app, path, constraints, defaults = {}) ⇒ Object
During route initialization, if a condition i18n_locale is present Delete it, store it in @locale, and add it to @defaults
398 399 400 401 402 403 404 405 406 407 |
# File 'lib/i18n_routing_rails32.rb', line 398 def initialize_with_i18n_routing(name, app, path, constraints, defaults = {}) @locale = if constraints.key?(:i18n_locale) c = defaults[:i18n_locale] = constraints.delete(:i18n_locale) # In rails 3.0 it's a regexp otherwise it's a string, so we need to call source on the regexp (c.respond_to?(:source) ? c.source : c).to_sym else nil end initialize_without_i18n_routing(name, app, path, constraints, defaults) end |