Class: ActsAsCalculatorEditor::ExportFormulas
- Inherits:
-
Object
- Object
- ActsAsCalculatorEditor::ExportFormulas
- Defined in:
- lib/acts_as_calculator_editor/export_formulas.rb
Overview
The formulas section of an import document — which is not the shape
SerializeFormula emits (docs/core-gem-contract.md §4.2). Four differences, each of
which would silently produce a file that does not round-trip:
- one flat entry per version, repeating
key/scope/owner, rather than a formula with a nestedversionsarray; owneras a{type, id}object, omitted entirely when nil;- no
id,formula_id,version_number,created_atorupdated_at— none of them are import keys; requiredwritten out as a real boolean, because the import default is "anything not literallyfalse" and omitting it is therefore not the same as round-tripping it.
Version order is load-bearing, not cosmetic. SupersedeFormulaVersions applies entries
in file order, so a version that takes over the tail of a range has to land after the
one giving it up; an out-of-order export re-imports straight into
PartialSupersedeError.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(key: nil, scope: nil, full_history: false) ⇒ ExportFormulas
constructor
A new instance of ExportFormulas.
Constructor Details
#initialize(key: nil, scope: nil, full_history: false) ⇒ ExportFormulas
Returns a new instance of ExportFormulas.
25 26 27 28 29 |
# File 'lib/acts_as_calculator_editor/export_formulas.rb', line 25 def initialize(key: nil, scope: nil, full_history: false) @key = key @scope = scope @full_history = full_history end |
Class Method Details
.call ⇒ Object
21 22 23 |
# File 'lib/acts_as_calculator_editor/export_formulas.rb', line 21 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
31 32 33 |
# File 'lib/acts_as_calculator_editor/export_formulas.rb', line 31 def call formulas.flat_map { |formula| versions(formula).map { |version| entry(formula, version) } } end |