Class: ActsAsCalculatorEditor::DeleteLookupTable
- Inherits:
-
Object
- Object
- ActsAsCalculatorEditor::DeleteLookupTable
- Defined in:
- lib/acts_as_calculator_editor/delete_lookup_table.rb
Overview
Nothing in the schema stops a lookup table from being deleted out from under a formula
that reads it: a variable names its table by key, not by foreign key, so there is no
constraint to lean on and MissingLookupTableError would only surface at the next
calculation.
ImportLookupTable refuses to rewrite brackets an active or retired version resolved
to, for the reason that rewriting them retroactively changes what an audited calculation
was measured against. Deleting the table is the same act with a worse ending, so it gets
the same guard and the same error class — reusing FindLookupTableReferences rather
than approximating it, since which table a formula resolves to depends on owner
shadowing and cannot be answered by matching keys.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(lookup_table:) ⇒ DeleteLookupTable
constructor
A new instance of DeleteLookupTable.
Constructor Details
#initialize(lookup_table:) ⇒ DeleteLookupTable
Returns a new instance of DeleteLookupTable.
20 21 22 |
# File 'lib/acts_as_calculator_editor/delete_lookup_table.rb', line 20 def initialize(lookup_table:) @lookup_table = lookup_table end |
Class Method Details
.call ⇒ Object
16 17 18 |
# File 'lib/acts_as_calculator_editor/delete_lookup_table.rb', line 16 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 |
# File 'lib/acts_as_calculator_editor/delete_lookup_table.rb', line 24 def call raise ActsAsCalculator::LookupTableInUseError, unless references.empty? lookup_table.destroy! lookup_table end |