Class: InlineTranslation::Translators::Base
- Inherits:
-
Object
- Object
- InlineTranslation::Translators::Base
- Defined in:
- lib/inline_translation/translators/base.rb
Instance Attribute Summary collapse
-
#translator ⇒ Object
readonly
Returns the value of attribute translator.
Class Method Summary collapse
Instance Method Summary collapse
- #can_translate?(translatable, field, to) ⇒ Boolean
- #translate(text, from: nil, to: I18n.locale) ⇒ Object
Instance Attribute Details
#translator ⇒ Object (readonly)
Returns the value of attribute translator.
4 5 6 |
# File 'lib/inline_translation/translators/base.rb', line 4 def translator @translator end |
Class Method Details
.ready? ⇒ Boolean
6 7 8 |
# File 'lib/inline_translation/translators/base.rb', line 6 def self.ready? false end |
Instance Method Details
#can_translate?(translatable, field, to) ⇒ Boolean
10 11 12 13 14 15 16 17 |
# File 'lib/inline_translation/translators/base.rb', line 10 def can_translate?(translatable, field, to) self.class.ready? && to.present? && translatable.respond_to?(field) && translatable.language_field.present? && translatable.language_field.to_s != to.to_s && translatable.translations.where(field: field, language: to).empty? end |
#translate(text, from: nil, to: I18n.locale) ⇒ Object
19 20 21 |
# File 'lib/inline_translation/translators/base.rb', line 19 def translate(text, from: nil, to: I18n.locale) raise NotImplementedError.new end |