Class: TypedCache::CacheDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/typed_cache/cache_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_configObject (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_configsObject (readonly)

: Array



48
49
50
# File 'lib/typed_cache/cache_builder.rb', line 48

def decorator_configs
  @decorator_configs
end

#instrumenter_sourceObject (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, **options)
  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, **options)
  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