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: Wipe features and gate values and then import features and gate values from provided adapter.
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/flipper/adapter.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#default_config ⇒ Object
Public: Default config for a feature’s gate values.
51 52 53 |
# File 'lib/flipper/adapter.rb', line 51 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.
24 25 26 27 |
# File 'lib/flipper/adapter.rb', line 24 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.
32 33 34 35 36 37 38 |
# File 'lib/flipper/adapter.rb', line 32 def get_multi(features) result = {} features.each do |feature| result[feature.key] = get(feature) end result end |
#import(source_adapter) ⇒ Object
Public: Wipe features and gate values and then import features and gate values from provided adapter.
Returns nothing.
44 45 46 47 48 |
# File 'lib/flipper/adapter.rb', line 44 def import(source_adapter) wipe copy_features_and_gates(source_adapter) nil end |