Class: TypedCache::CacheDefinition
- Inherits:
-
Object
- Object
- TypedCache::CacheDefinition
- Defined in:
- lib/typed_cache/cache_builder.rb
Instance Attribute Summary collapse
-
#backend_config ⇒ Object
readonly
@rbs! type instrumenter_source = :default | :dry | :rails | Instrumenter.
-
#decorator_configs ⇒ Object
readonly
: Array.
-
#instrumenter_source ⇒ Object
readonly
: instrumenter_source.
Instance Method Summary collapse
-
#initialize(backend_config = nil, decorator_configs = [], instrumenter_source = nil) ⇒ CacheDefinition
constructor
A new instance of CacheDefinition.
- #with_backend(name, *args, **options) ⇒ Object
- #with_decorator(name, **options) ⇒ Object
- #with_instrumentation(source = :default) ⇒ Object
Constructor Details
#initialize(backend_config = nil, decorator_configs = [], instrumenter_source = nil) ⇒ CacheDefinition
Returns a new instance of CacheDefinition.
52 53 54 55 56 |
# File 'lib/typed_cache/cache_builder.rb', line 52 def initialize(backend_config = nil, decorator_configs = [], instrumenter_source = nil) @backend_config = backend_config @decorator_configs = decorator_configs @instrumenter_source = instrumenter_source end |
Instance Attribute Details
#backend_config ⇒ Object (readonly)
@rbs! type instrumenter_source = :default | :dry | :rails | Instrumenter
47 48 49 |
# File 'lib/typed_cache/cache_builder.rb', line 47 def backend_config @backend_config end |
#decorator_configs ⇒ Object (readonly)
: Array
48 49 50 |
# File 'lib/typed_cache/cache_builder.rb', line 48 def decorator_configs @decorator_configs end |
#instrumenter_source ⇒ Object (readonly)
: instrumenter_source
49 50 51 |
# File 'lib/typed_cache/cache_builder.rb', line 49 def instrumenter_source @instrumenter_source end |
Instance Method Details
#with_backend(name, *args, **options) ⇒ Object
60 61 62 |
# File 'lib/typed_cache/cache_builder.rb', line 60 def with_backend(name, *args, **) self.class.new(BackendConfig.new(name:, args:, options:), @decorator_configs) end |
#with_decorator(name, **options) ⇒ Object
66 67 68 |
# File 'lib/typed_cache/cache_builder.rb', line 66 def with_decorator(name, **) self.class.new(@backend_config, @decorator_configs + [DecoratorConfig.new(name:, options:)]) end |
#with_instrumentation(source = :default) ⇒ Object
72 73 74 |
# File 'lib/typed_cache/cache_builder.rb', line 72 def with_instrumentation(source = :default) self.class.new(@backend_config, @decorator_configs, source) end |