Class: Purizumu::Engines::Test
- Inherits:
-
Object
- Object
- Purizumu::Engines::Test
- Defined in:
- lib/purizumu/engines/test.rb
Overview
Translation engine used in test mode. It never performs network requests; it returns a deterministic stub translation, or the result of the handler given to Purizumu.test_mode!.
Instance Method Summary collapse
-
#initialize(handler: nil) ⇒ Test
constructor
A new instance of Test.
- #translate(model_name:, attribute_name:, content:, locale:, source_locale:) ⇒ Object
Constructor Details
#initialize(handler: nil) ⇒ Test
Returns a new instance of Test.
9 10 11 |
# File 'lib/purizumu/engines/test.rb', line 9 def initialize(handler: nil) @handler = handler end |
Instance Method Details
#translate(model_name:, attribute_name:, content:, locale:, source_locale:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/purizumu/engines/test.rb', line 13 def translate(model_name:, attribute_name:, content:, locale:, source_locale:) if handler handler.call( model_name:, attribute_name:, content:, locale:, source_locale: ).to_s else "[#{locale}] #{content}" end end |