Class: Rigor::Cache::RbsCacheProducer

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/cache/rbs_cache_producer.rb

Overview

Base for the RBS-derived cache producers.

Every producer (‘RbsKnownClassNames`, `RbsConstantTable`, `RbsEnvironment`, the ancestor / type-param / definition tables, …) repeated the identical `fetch` wiring: build the RBS descriptor, then `store.fetch_or_compute` under the producer’s id, yielding to the producer’s ‘compute`. Only the `PRODUCER_ID` constant and the `compute(loader)` body actually differ between producers.

Subclasses declare ‘PRODUCER_ID` and a (private) `self.compute`; this base owns `fetch`. `self::PRODUCER_ID` resolves the constant on the concrete subclass, and `compute(loader)` dispatches to its private class method. See the `_CacheProducer` RBS interface for the structural contract.

Class Method Summary collapse

Class Method Details

.fetch(loader:, store:) ⇒ Object



22
23
24
25
26
27
# File 'lib/rigor/cache/rbs_cache_producer.rb', line 22

def self.fetch(loader:, store:)
  descriptor = RbsDescriptor.build(loader)
  store.fetch_or_compute(producer_id: self::PRODUCER_ID, params: {}, descriptor: descriptor) do
    compute(loader)
  end
end