Class: ActsAsCalculatorEditor::CastExportDecimal
- Inherits:
-
Object
- Object
- ActsAsCalculatorEditor::CastExportDecimal
- Defined in:
- lib/acts_as_calculator_editor/cast_export_decimal.rb
Overview
Lookup bounds and values are decimal(20, 6), and a float round-trip loses precision
above 15 significant digits — on numbers that are tax brackets. So they leave as JSON
strings, which CastDecimal parses back without ceremony.
to_s("F") rather than plain to_s, which renders 0.1 as "0.1e0". The core gem
makes the same choice writing decimals into source_config (CastJsonSafe), so an
exported file and an imported one agree on what a decimal looks like.
Class Method Summary collapse
Class Method Details
.call(value) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/acts_as_calculator_editor/cast_export_decimal.rb', line 12 def self.call(value) return nil if value.nil? return value.to_s("F") if value.is_a?(BigDecimal) ActsAsCalculator::CastDecimal.(value).to_s("F") end |