module RoutingFilter

Public Instance Methods

around_generate(params) { || ... } click to toggle source
# File lib/refinery/i18n-filter.rb, line 22
def around_generate(params, &block)
  locale = params.delete(:locale) || ::I18n.locale

  yield.tap do |result|
    result = result.is_a?(Array) ? result.first : result
    if ::Refinery::I18n.url_filter_enabled? and
       locale != ::Refinery::I18n.default_frontend_locale and
       result !~ %r{^/(#{Refinery::Core.backend_route}|wymiframe)}
      result.sub!(%r(^(http.?://[^/]*)?(.*))) { "#{$1}/#{locale}#{$2}" }
    end
  end