Class: ThisFeature::Adapters::SplitIo

Inherits:
Base
  • Object
show all
Defined in:
lib/this_feature/adapters/split_io.rb

Constant Summary collapse

UNDEFINED_KEY =

used as treatment key when none is given, it’s required by split

'undefined_key'

Instance Method Summary collapse

Methods inherited from Base

#setup

Constructor Details

#initialize(client: nil) ⇒ SplitIo

Returns a new instance of SplitIo.



9
10
11
12
13
# File 'lib/this_feature/adapters/split_io.rb', line 9

def initialize(client: nil)
  @client = client || default_split_client

  @client.block_until_ready
end

Instance Method Details

#control?(flag_name, context: UNDEFINED_KEY, data: {}) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/this_feature/adapters/split_io.rb', line 19

def control?(flag_name, context: UNDEFINED_KEY, data: {})
  treatment(flag_name, context: context, data: data).include?('control')
end

#off?(flag_name, context: UNDEFINED_KEY, data: {}) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/this_feature/adapters/split_io.rb', line 27

def off?(flag_name, context: UNDEFINED_KEY, data: {})
  treatment(flag_name, context: context, data: data).eql?('off')
end

#on?(flag_name, context: UNDEFINED_KEY, data: {}) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/this_feature/adapters/split_io.rb', line 23

def on?(flag_name, context: UNDEFINED_KEY, data: {})
  treatment(flag_name, context: context, data: data).eql?('on')
end

#present?(flag_name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/this_feature/adapters/split_io.rb', line 15

def present?(flag_name)
  !control?(flag_name)
end