Class: ThisFeature

Inherits:
Object
  • Object
show all
Defined in:
lib/this_feature.rb,
lib/this_feature/flag.rb,
lib/this_feature/errors.rb,
lib/this_feature/version.rb,
lib/this_feature/adapters.rb,
lib/this_feature/adapters/base.rb,
lib/this_feature/configuration.rb,
lib/this_feature/adapters/memory.rb,
lib/this_feature/adapters/flipper.rb,
lib/this_feature/adapters/split_io.rb

Defined Under Namespace

Modules: Adapters Classes: BadAdapterError, Configuration, Error, Flag, NoAdaptersError, UnimplementedError

Constant Summary collapse

VERSION =
"0.6.0"

Class Method Summary collapse

Class Method Details

.adapter_for(flag_name, context: nil, data: {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/this_feature.rb', line 14

def self.adapter_for(flag_name, context: nil, data: {})
  matching_adapter = adapters.find do |adapter|
    adapter.present?(flag_name)
  end

  matching_adapter || configuration.default_adapter
end

.adaptersObject



34
35
36
# File 'lib/this_feature.rb', line 34

def self.adapters
  configuration.adapters
end

.configurationObject



22
23
24
# File 'lib/this_feature.rb', line 22

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



26
27
28
29
30
31
32
# File 'lib/this_feature.rb', line 26

def self.configure
  @configuration = Configuration.new

  yield(configuration)

  configuration.init
end

.flag(flag_name, context: nil, data: {}) ⇒ Object



8
9
10
11
12
# File 'lib/this_feature.rb', line 8

def self.flag(flag_name, context: nil, data: {})
  adapter = adapter_for(flag_name, context: nil, data: {})

  Flag.new(flag_name, adapter: adapter, context: context, data: data)
end

.test_adapterObject



38
39
40
# File 'lib/this_feature.rb', line 38

def self.test_adapter
  configuration.test_adapter
end