Class: AbstractController::I18nProxy

Inherits:
I18n::Config
  • Object
show all
Defined in:
actionpack/lib/abstract_controller/rendering.rb

Overview

This is a class to fix I18n global state. Whenever you provide I18n.locale during a request, it will trigger the lookup_context and consequently expire the cache.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_config, lookup_context) ⇒ I18nProxy

Returns a new instance of I18nProxy


18
19
20
21
# File 'actionpack/lib/abstract_controller/rendering.rb', line 18

def initialize(original_config, lookup_context)
  original_config = original_config.original_config if original_config.respond_to?(:original_config)
  @original_config, @lookup_context = original_config, lookup_context
end

Instance Attribute Details

#lookup_contextObject (readonly)

:nodoc:


16
17
18
# File 'actionpack/lib/abstract_controller/rendering.rb', line 16

def lookup_context
  @lookup_context
end

#original_configObject (readonly)

:nodoc:


16
17
18
# File 'actionpack/lib/abstract_controller/rendering.rb', line 16

def original_config
  @original_config
end

Instance Method Details

#localeObject


23
24
25
# File 'actionpack/lib/abstract_controller/rendering.rb', line 23

def locale
  @original_config.locale
end

#locale=(value) ⇒ Object


27
28
29
# File 'actionpack/lib/abstract_controller/rendering.rb', line 27

def locale=(value)
  @lookup_context.locale = value
end