Module: Flipper::Adapter
- Included in:
- Flipper::Adapters::Http, Flipper::Adapters::Instrumented, Flipper::Adapters::Memoizable, Flipper::Adapters::Memory, Flipper::Adapters::OperationLogger, Flipper::Adapters::PStore, Flipper::Adapters::ReadOnly, Flipper::Adapters::Sync
- Defined in:
- lib/flipper/adapter.rb
Overview
Adding a module include so we have some hooks for stuff down the road
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#default_config ⇒ Object
Public: Default config for a feature’s gate values.
-
#get_all ⇒ Object
Public: Get all features and gate values in one call.
-
#get_multi(features) ⇒ Object
Public: Get multiple features in one call.
-
#import(source_adapter) ⇒ Object
Public: Ensure that adapter is in sync with source adapter provided.
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/flipper/adapter.rb', line 6 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#default_config ⇒ Object
Public: Default config for a feature’s gate values.
50 51 52 |
# File 'lib/flipper/adapter.rb', line 50 def default_config self.class.default_config end |
#get_all ⇒ Object
Public: Get all features and gate values in one call. Defaults to one call to features and another to get_multi. Feel free to override per adapter to make this more efficient.
26 27 28 29 |
# File 'lib/flipper/adapter.rb', line 26 def get_all instances = features.map { |key| Flipper::Feature.new(key, self) } get_multi(instances) end |
#get_multi(features) ⇒ Object
Public: Get multiple features in one call. Defaults to one get per feature. Feel free to override per adapter to make this more efficient and reduce network calls.
34 35 36 37 38 39 40 |
# File 'lib/flipper/adapter.rb', line 34 def get_multi(features) result = {} features.each do |feature| result[feature.key] = get(feature) end result end |
#import(source_adapter) ⇒ Object
Public: Ensure that adapter is in sync with source adapter provided.
Returns result of Synchronizer#call.
45 46 47 |
# File 'lib/flipper/adapter.rb', line 45 def import(source_adapter) Adapters::Sync::Synchronizer.new(self, source_adapter, raise: true).call end |