Class: Flipper::Adapters::Strict
- Inherits:
-
Object
- Object
- Flipper::Adapters::Strict
- Extended by:
- Forwardable
- Includes:
- Flipper::Adapter
- Defined in:
- lib/flipper/adapters/strict.rb
Overview
An adapter that ensures a feature exists before checking it.
Defined Under Namespace
Classes: NotFound
Constant Summary collapse
- HANDLERS =
{ raise: ->(feature) { raise NotFound.new(feature.key) }, warn: ->(feature) { warn NotFound.new(feature.key). }, noop: ->(_) { }, }
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #get(feature) ⇒ Object
- #get_multi(features) ⇒ Object
-
#initialize(adapter, handler = nil, &block) ⇒ Strict
constructor
A new instance of Strict.
Methods included from Flipper::Adapter
#default_config, #export, #get_all, #import, included
Constructor Details
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/flipper/adapters/strict.rb', line 7 def adapter @adapter end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
7 8 9 |
# File 'lib/flipper/adapters/strict.rb', line 7 def handler @handler end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/flipper/adapters/strict.rb', line 7 def name @name end |
Instance Method Details
#get(feature) ⇒ Object
29 30 31 32 |
# File 'lib/flipper/adapters/strict.rb', line 29 def get(feature) assert_feature_exists(feature) @adapter.get(feature) end |
#get_multi(features) ⇒ Object
34 35 36 37 |
# File 'lib/flipper/adapters/strict.rb', line 34 def get_multi(features) features.each { |feature| assert_feature_exists(feature) } @adapter.get_multi(features) end |