Class: Flipper::Adapters::Wrapper

Inherits:
Object
  • Object
show all
Includes:
Flipper::Adapter
Defined in:
lib/flipper/adapters/wrapper.rb

Overview

A base class for any adapter that wraps another adapter. By default, all methods delegate to the wrapped adapter. Implement ‘#wrap` to customize the behavior of all delegated methods, or override individual methods as needed.

Direct Known Subclasses

ActorLimit, OperationLogger, ReadOnly, Strict

Constant Summary collapse

METHODS =
[
  :import,
  :export,
  :features,
  :add,
  :remove,
  :clear,
  :get,
  :get_multi,
  :get_all,
  :enable,
  :disable,
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Flipper::Adapter

#default_config, #export, #get_all, #get_multi, #import, included, #name, #read_only?

Constructor Details

#initialize(adapter) ⇒ Wrapper

Returns a new instance of Wrapper.



25
26
27
# File 'lib/flipper/adapters/wrapper.rb', line 25

def initialize(adapter)
  @adapter = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



23
24
25
# File 'lib/flipper/adapters/wrapper.rb', line 23

def adapter
  @adapter
end

Instance Method Details

#wrap(method, *args, &block) ⇒ Object



44
45
46
# File 'lib/flipper/adapters/wrapper.rb', line 44

def wrap(method, *args, **kwargs, &block)
  block.call
end