Sha256: e61e96db878a19216dff4bf0fde669ed4fea1e7dff86be0d6f13a6942372e221

Contents?: true

Size: 880 Bytes

Versions: 9

Compression:

Stored size: 880 Bytes

Contents

require 'casino'
require 'http_accept_language'

class CASino::ApplicationController < ::ApplicationController
  include ApplicationHelper

  layout 'application'
  before_filter :set_locale

  def cookies
    super
  end

  protected
  def processor(processor_name, listener_name = nil)
    listener_name ||= processor_name
    listener = CASino.const_get(:"#{listener_name}Listener").new(self)
    @processor = CASino.const_get(:"#{processor_name}Processor").new(listener)
  end

  def set_locale
    I18n.locale = extract_locale_from_accept_language_header || I18n.default_locale
  end

  def extract_locale_from_accept_language_header
    if request.env['HTTP_ACCEPT_LANGUAGE']
      http_accept_language.preferred_language_from(I18n.available_locales)
    end
  end

  def http_accept_language
    HttpAcceptLanguage::Parser.new request.env['HTTP_ACCEPT_LANGUAGE']
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
casino-2.0.7 app/controllers/casino/application_controller.rb
casino-3.0.0.pre.1 app/controllers/casino/application_controller.rb
casino-2.0.6 app/controllers/casino/application_controller.rb
casino-2.0.5 app/controllers/casino/application_controller.rb
casino-2.0.4 app/controllers/casino/application_controller.rb
casino-2.0.3 app/controllers/casino/application_controller.rb
casino-2.0.2 app/controllers/casino/application_controller.rb
casino-2.0.1 app/controllers/casino/application_controller.rb
casino-2.0.0 app/controllers/casino/application_controller.rb