Sha256: 8130ff2060589c6a1cf37bb2ba26caef140d44d0f8992195d77d5f2d20651510

Contents?: true

Size: 411 Bytes

Versions: 1

Compression:

Stored size: 411 Bytes

Contents

class LanguageContext
  def key
    :lang
  end

  def required?
    false
  end

  def constraints
    Regexp.new(I18n.available_locales.join('|'))
  end

  def default
    I18n.default_locale
  end

  def current
    I18n.locale
  end

  def apply(controller, value)
    I18n.locale = value || controller.params[key].presence || default
  end

  def url_option
    current unless current == default
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contexts-1.1.0 spec/dummy/app/contexts/language_context.rb