Class: ActsAsCalculator::FindLookupTableReferences

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_calculator/find_lookup_table_references.rb

Overview

Which formula versions would resolve to this lookup table if they ran now.

A variable names a table by key, never by id, and BuildLookups turns that key into a row through FindOwnedRecord — owner first, global second. So "does version X use table Y" cannot be answered by a foreign key or by matching keys alone: a global table is used by an owned formula only when that owner has no table of its own with the same key. Re-running the very same resolution is what keeps this answer from drifting away from what an actual calculation would do.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lookup_table:, statuses: nil) ⇒ FindLookupTableReferences

Returns a new instance of FindLookupTableReferences.



17
18
19
20
# File 'lib/acts_as_calculator/find_lookup_table_references.rb', line 17

def initialize(lookup_table:, statuses: nil)
  @lookup_table = lookup_table
  @statuses = statuses
end

Class Method Details

.callObject



13
14
15
# File 'lib/acts_as_calculator/find_lookup_table_references.rb', line 13

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject



22
23
24
25
26
# File 'lib/acts_as_calculator/find_lookup_table_references.rb', line 22

def call
  candidates.select { |variable| resolves_here?(variable.formula_version.formula) }
            .map(&:formula_version)
            .uniq
end