Class: Stockboy::Translations::DefaultEmptyString
- Inherits:
-
Stockboy::Translator
- Object
- Stockboy::Translator
- Stockboy::Translations::DefaultEmptyString
- Defined in:
- lib/stockboy/translations/default_empty_string.rb
Overview
Translate missing values to empty string
This is a useful fallback for translation errors.
Job template DSL
Registered as :or_empty
. Use with:
attributes do
product_code as: [->(r){raise "Invalid"}, :or_empty]
end
Instance Attribute Summary
Attributes inherited from Stockboy::Translator
Instance Method Summary collapse
Methods inherited from Stockboy::Translator
Constructor Details
This class inherits a constructor from Stockboy::Translator
Instance Method Details
#translate(context) ⇒ String
30 31 32 33 34 35 |
# File 'lib/stockboy/translations/default_empty_string.rb', line 30 def translate(context) value = field_value(context, field_key) return "" if (value).blank? return value end |