Class: I18n::Backend::Callbacks
- Inherits:
-
Delegator
- Object
- Delegator
- I18n::Backend::Callbacks
- Defined in:
- lib/i18n/backend/callbacks.rb
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#before ⇒ Object
Returns the value of attribute before.
-
#wrapped ⇒ Object
readonly
Returns the value of attribute wrapped.
Instance Method Summary collapse
- #__getobj__ ⇒ Object
-
#__setobj__(obj) ⇒ Object
implement the Delegator interface.
-
#initialize(wrapped, before: nil, after: nil) ⇒ Callbacks
constructor
A new instance of Callbacks.
- #translate(locale, key, options = {}) ⇒ Object
Constructor Details
#initialize(wrapped, before: nil, after: nil) ⇒ Callbacks
Returns a new instance of Callbacks.
8 9 10 11 12 13 |
# File 'lib/i18n/backend/callbacks.rb', line 8 def initialize(wrapped, before: nil, after: nil) super(wrapped) @wrapped = wrapped @before = before @after = after end |
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after.
6 7 8 |
# File 'lib/i18n/backend/callbacks.rb', line 6 def after @after end |
#before ⇒ Object
Returns the value of attribute before.
5 6 7 |
# File 'lib/i18n/backend/callbacks.rb', line 5 def before @before end |
#wrapped ⇒ Object (readonly)
Returns the value of attribute wrapped.
4 5 6 |
# File 'lib/i18n/backend/callbacks.rb', line 4 def wrapped @wrapped end |
Instance Method Details
#__getobj__ ⇒ Object
28 29 30 |
# File 'lib/i18n/backend/callbacks.rb', line 28 def __getobj__ wrapped end |
#__setobj__(obj) ⇒ Object
implement the Delegator interface
24 25 26 |
# File 'lib/i18n/backend/callbacks.rb', line 24 def __setobj__(obj) @wrapped = obj end |
#translate(locale, key, options = {}) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/i18n/backend/callbacks.rb', line 15 def translate(locale, key, = {}) locale, key, = before.call(locale, key, ) if before result = wrapped.translate(locale, key, ) result = after.call(locale, key, , result) if after result end |