Sha256: 2e5116bd370560d5aac687e4a960ebe4b26e17797d0274d8d7ca3c60703236b0

Contents?: true

Size: 374 Bytes

Versions: 1

Compression:

Stored size: 374 Bytes

Contents

class LanguageContext
  def key
    :lang
  end

  def required?
    false
  end

  def constraints
    /ru|en/
  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.0.0 spec/dummy/app/contexts/language_context.rb