Class: Flipper::Adapters::Strict

Inherits:
Wrapper
  • Object
show all
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

Constants inherited from Wrapper

Wrapper::METHODS

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#adapter

Instance Method Summary collapse

Methods inherited from Wrapper

#wrap

Methods included from Flipper::Adapter

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

Constructor Details

#initialize(adapter, handler = nil, &block) ⇒ Strict

Returns a new instance of Strict.



13
14
15
16
# File 'lib/flipper/adapters/strict.rb', line 13

def initialize(adapter, handler = nil, &block)
  super(adapter)
  @handler = block || handler
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



5
6
7
# File 'lib/flipper/adapters/strict.rb', line 5

def handler
  @handler
end

Instance Method Details

#get(feature) ⇒ Object



18
19
20
21
# File 'lib/flipper/adapters/strict.rb', line 18

def get(feature)
  assert_feature_exists(feature)
  super
end

#get_multi(features) ⇒ Object



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

def get_multi(features)
  features.each { |feature| assert_feature_exists(feature) }
  super
end