Class: ClientWithContext

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_sdk/client_with_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(context_obj) ⇒ ClientWithContext

Returns a new instance of ClientWithContext.



4
5
6
7
8
# File 'lib/ruby_sdk/client_with_context.rb', line 4

def initialize(context_obj)
  @context = context_obj[:context]
  @client = context_obj[:client]
  @config = context_obj[:config]
end

Instance Method Details

#add_google_analytics_collector(config_object) ⇒ Object



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

def add_google_analytics_collector(config_object)
  @client.add_google_analytics_collector(config_object)  
end

#get_feature(key, default_value = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ruby_sdk/client_with_context.rb', line 10

def get_feature(key, default_value = nil)
  feature_state = @client.get_feature_state(key)
  return HandleUndefinedFeature.handle(key, default_value) if !feature_state

  # if value of flag is true, use rollout
  if feature_state.value
    return feature_state.strategy.calculate(@context)
  else
    return feature_state.value
  end
end

#log_event(event_object) ⇒ Object



26
27
28
# File 'lib/ruby_sdk/client_with_context.rb', line 26

def log_event(event_object)
  @client.log_event(event_object)
end