Module: Flipper::Adapter
- Included in:
- Flipper::Adapters::ActiveRecord, Flipper::Adapters::CacheBase, Flipper::Adapters::DualWrite, Flipper::Adapters::Failover, Flipper::Adapters::Failsafe, Flipper::Adapters::Http, Flipper::Adapters::Instrumented, Flipper::Adapters::Memoizable, Flipper::Adapters::Memory, Flipper::Adapters::Moneta, Flipper::Adapters::Mongo, Flipper::Adapters::PStore, Flipper::Adapters::Poll, Flipper::Adapters::Redis, Flipper::Adapters::Rollout, Flipper::Adapters::Sequel, Flipper::Adapters::Sync, Flipper::Adapters::Wrapper
- 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.
-
#export(format: :json, version: 1) ⇒ Object
Public: Exports the adapter in a given format for a given format version.
-
#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) ⇒ Object
Public: Ensure that adapter is in sync with source adapter provided.
-
#name ⇒ Object
Public: default name of the adapter.
- #read_only? ⇒ Boolean
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.
68 69 70 |
# File 'lib/flipper/adapter.rb', line 68 def default_config self.class.default_config end |
#export(format: :json, version: 1) ⇒ Object
Public: Exports the adapter in a given format for a given format version.
Returns a Flipper::Export instance.
63 64 65 |
# File 'lib/flipper/adapter.rb', line 63 def export(format: :json, version: 1) Flipper::Exporter.build(format: format, version: version).call(self) 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.
34 35 36 37 |
# File 'lib/flipper/adapter.rb', line 34 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.
42 43 44 45 46 47 48 |
# File 'lib/flipper/adapter.rb', line 42 def get_multi(features) result = {} features.each do |feature| result[feature.key] = get(feature) end result end |
#import(source) ⇒ Object
Public: Ensure that adapter is in sync with source adapter provided.
source - The source dsl, adapter or export to import.
Returns true if successful.
55 56 57 58 |
# File 'lib/flipper/adapter.rb', line 55 def import(source) Adapters::Sync::Synchronizer.new(self, self.class.from(source), raise: true).call true end |
#name ⇒ Object
Public: default name of the adapter
73 74 75 |
# File 'lib/flipper/adapter.rb', line 73 def name @name ||= self.class.name.split('::').last.split(/(?=[A-Z])/).join('_').downcase.to_sym end |
#read_only? ⇒ Boolean
27 28 29 |
# File 'lib/flipper/adapter.rb', line 27 def read_only? false end |