Class: TranslationDiff::Context
- Inherits:
-
Object
- Object
- TranslationDiff::Context
- Defined in:
- lib/translation_diff/context.rb
Overview
An isolated configuration scope with the same entry point as TranslationDiff itself.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ Context
constructor
A new instance of Context.
-
#preview(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
Answers what #translate would do to
valuesunder this context's own configuration, without calling it. - #translate(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
Constructor Details
#initialize(config) ⇒ Context
Returns a new instance of Context.
5 6 7 |
# File 'lib/translation_diff/context.rb', line 5 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/translation_diff/context.rb', line 3 def config @config end |
Instance Method Details
#preview(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
Answers what #translate would do to values under this context's own configuration, without calling it.
17 18 19 20 21 22 |
# File 'lib/translation_diff/context.rb', line 17 def preview(values, from: nil, to: nil, provider: nil, assume_supported: false, **) TranslationDiff::Previewer.new( values, from: from, to: to, provider: provider, config: config, assume_supported: assume_supported, ** ).call end |
#translate(values, from: nil, to: nil, provider: nil, assume_supported: false) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/translation_diff/context.rb', line 9 def translate(values, from: nil, to: nil, provider: nil, assume_supported: false, **) TranslationDiff::Translator.new( values, from: from, to: to, provider: provider, config: config, assume_supported: assume_supported, ** ).call end |