Class: Stockboy::Translations::DefaultZero
- Inherits:
-
Stockboy::Translator
- Object
- Stockboy::Translator
- Stockboy::Translations::DefaultZero
- Defined in:
- lib/stockboy/translations/default_zero.rb
Overview
Translate missing values to numeric zero
This is a useful fallback for translation errors.
Job template DSL
Registered as :or_zero
. Use with:
attributes do
cost as: [->(r){raise "Invalid"}, :or_zero]
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) ⇒ Integer
33 34 35 36 37 38 |
# File 'lib/stockboy/translations/default_zero.rb', line 33 def translate(context) value = field_value(context, field_key) return 0 if value.blank? return value end |