Class: ThisFeature::Adapters::SplitIo
- Defined in:
- lib/this_feature/adapters/split_io.rb
Constant Summary collapse
- EMPTY_CONTEXT =
Used as the context key when none is given. This arg is required by Split, but it’s nice not to have to pass it when the context is empty.
'undefined_key'.freeze
Instance Method Summary collapse
- #control?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Boolean
-
#initialize(client: nil, context_key_method: nil) ⇒ SplitIo
constructor
A new instance of SplitIo.
- #off?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Boolean
- #on?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Boolean
- #present?(flag_name) ⇒ Boolean
- #treatment_config(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Object
- #treatment_value(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Object
Constructor Details
#initialize(client: nil, context_key_method: nil) ⇒ SplitIo
Returns a new instance of SplitIo.
10 11 12 13 14 15 |
# File 'lib/this_feature/adapters/split_io.rb', line 10 def initialize(client: nil, context_key_method: nil) @client = client || default_split_client @context_key_method = context_key_method @client.block_until_ready end |
Instance Method Details
#control?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Boolean
21 22 23 |
# File 'lib/this_feature/adapters/split_io.rb', line 21 def control?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) treatment(flag_name, context: context, data: data, record: record).include?('control') end |
#off?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Boolean
29 30 31 |
# File 'lib/this_feature/adapters/split_io.rb', line 29 def off?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) treatment(flag_name, context: context, data: data, record: record).eql?('off') end |
#on?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Boolean
25 26 27 |
# File 'lib/this_feature/adapters/split_io.rb', line 25 def on?(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) treatment(flag_name, context: context, data: data, record: record).eql?('on') end |
#present?(flag_name) ⇒ Boolean
17 18 19 |
# File 'lib/this_feature/adapters/split_io.rb', line 17 def present?(flag_name) !control?(flag_name) end |
#treatment_config(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Object
37 38 39 |
# File 'lib/this_feature/adapters/split_io.rb', line 37 def treatment_config(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) treatment_with_config(flag_name, context: context, data: data, record: record)[:config] end |
#treatment_value(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) ⇒ Object
33 34 35 |
# File 'lib/this_feature/adapters/split_io.rb', line 33 def treatment_value(flag_name, context: EMPTY_CONTEXT, data: {}, record: nil) treatment_with_config(flag_name, context: context, data: data, record: record)[:treatment] end |