Sha256: 0ba3a1a716fbe4873ec08eb3f281a73c5bb133baab59df103a25086ff535f228

Contents?: true

Size: 317 Bytes

Versions: 1

Compression:

Stored size: 317 Bytes

Contents

class LanguageContext < Contexts::Base
  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(ctrl, value)
    I18n.locale = value || ctrl.params[key].presence || default
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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