Class: Featureflip::Client
- Inherits:
-
Object
- Object
- Featureflip::Client
- Defined in:
- lib/featureflip/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bool_variation(key, context, default_value) ⇒ Object
- #close ⇒ Object
- #flush ⇒ Object
- #identify(context) ⇒ Object
- #initialized? ⇒ Boolean
- #json_variation(key, context, default_value) ⇒ Object
- #number_variation(key, context, default_value) ⇒ Object
- #restart ⇒ Object
- #string_variation(key, context, default_value) ⇒ Object
- #track(event_key, context, metadata = nil) ⇒ Object
- #variation_detail(key, context, default_value) ⇒ Object
Class Method Details
.for_testing(flags) ⇒ Object
14 15 16 17 |
# File 'lib/featureflip/client.rb', line 14 def self.for_testing(flags) core = SharedCore._create_for_testing(flags) new(core) end |
.get(sdk_key = nil, config: nil) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/featureflip/client.rb', line 5 def self.get(sdk_key = nil, config: nil) sdk_key ||= ENV["FEATUREFLIP_SDK_KEY"] raise ConfigurationError, "SDK key is required. Pass sdk_key parameter or set FEATUREFLIP_SDK_KEY env var." unless sdk_key config ||= Config.new core = SharedCore._get_or_create(sdk_key, config) new(core) end |
Instance Method Details
#bool_variation(key, context, default_value) ⇒ Object
23 24 25 26 |
# File 'lib/featureflip/client.rb', line 23 def bool_variation(key, context, default_value) return default_value if @closed @core.bool_variation(key, context, default_value) end |
#close ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/featureflip/client.rb', line 65 def close @close_mutex.synchronize do return if @closed @closed = true end @core._release end |
#flush ⇒ Object
60 61 62 63 |
# File 'lib/featureflip/client.rb', line 60 def flush return if @closed @core.flush end |
#identify(context) ⇒ Object
55 56 57 58 |
# File 'lib/featureflip/client.rb', line 55 def identify(context) return if @closed @core.identify(context) end |
#initialized? ⇒ Boolean
19 20 21 |
# File 'lib/featureflip/client.rb', line 19 def initialized? @core.initialized? end |
#json_variation(key, context, default_value) ⇒ Object
38 39 40 41 |
# File 'lib/featureflip/client.rb', line 38 def json_variation(key, context, default_value) return default_value if @closed @core.json_variation(key, context, default_value) end |
#number_variation(key, context, default_value) ⇒ Object
33 34 35 36 |
# File 'lib/featureflip/client.rb', line 33 def number_variation(key, context, default_value) return default_value if @closed @core.number_variation(key, context, default_value) end |
#restart ⇒ Object
73 74 75 76 |
# File 'lib/featureflip/client.rb', line 73 def restart return if @closed @core.restart end |
#string_variation(key, context, default_value) ⇒ Object
28 29 30 31 |
# File 'lib/featureflip/client.rb', line 28 def string_variation(key, context, default_value) return default_value if @closed @core.string_variation(key, context, default_value) end |
#track(event_key, context, metadata = nil) ⇒ Object
50 51 52 53 |
# File 'lib/featureflip/client.rb', line 50 def track(event_key, context, = nil) return if @closed @core.track(event_key, context, ) end |
#variation_detail(key, context, default_value) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/featureflip/client.rb', line 43 def variation_detail(key, context, default_value) if @closed return Models::EvaluationDetail.new(value: default_value, reason: "Error") end @core.variation_detail(key, context, default_value) end |