Class: SplitIoClient::LocalhostSplitClient
- Inherits:
-
Object
- Object
- SplitIoClient::LocalhostSplitClient
- Includes:
- LocalhostUtils
- Defined in:
- lib/splitclient-rb/clients/localhost_split_client.rb
Instance Attribute Summary collapse
-
#localhost_mode ⇒ Object
readonly
variables to if the sdk is being used in localhost mode and store the list of features.
-
#localhost_mode_features ⇒ Object
readonly
Returns the value of attribute localhost_mode_features.
Class Method Summary collapse
-
.sdk_version ⇒ string
method that returns the sdk gem version.
Instance Method Summary collapse
-
#get_treatment(id, feature, attributes = nil) ⇒ Treatment
obtains the treatment for a given feature.
- #get_treatments(key, split_names, attributes = nil) ⇒ Object
-
#initialize(splits_file, reload_rate = nil) ⇒ LocalhostSplitIoClient
constructor
Creates a new split client instance that reads from the given splits file.
- #track ⇒ Object
Methods included from LocalhostUtils
#load_localhost_mode_features, #store_features
Constructor Details
#initialize(splits_file, reload_rate = nil) ⇒ LocalhostSplitIoClient
Creates a new split client instance that reads from the given splits file
16 17 18 19 20 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 16 def initialize(splits_file, reload_rate = nil) @localhost_mode = true @localhost_mode_features = [] load_localhost_mode_features(splits_file, reload_rate) end |
Instance Attribute Details
#localhost_mode ⇒ Object (readonly)
variables to if the sdk is being used in localhost mode and store the list of features
7 8 9 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 7 def localhost_mode @localhost_mode end |
#localhost_mode_features ⇒ Object (readonly)
Returns the value of attribute localhost_mode_features.
8 9 10 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 8 def localhost_mode_features @localhost_mode_features end |
Class Method Details
.sdk_version ⇒ string
method that returns the sdk gem version
26 27 28 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 26 def self.sdk_version 'ruby-'+SplitIoClient::VERSION end |
Instance Method Details
#get_treatment(id, feature, attributes = nil) ⇒ Treatment
obtains the treatment for a given feature
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 43 def get_treatment(id, feature, attributes = nil) unless id SplitIoClient.configuration.logger.warn('id was null for feature: ' + feature) return SplitIoClient::Engine::Models::Treatment::CONTROL end unless feature SplitIoClient.configuration.logger.warn('feature was null for id: ' + id) return SplitIoClient::Engine::Models::Treatment::CONTROL end result = get_localhost_treatment(feature) end |
#get_treatments(key, split_names, attributes = nil) ⇒ Object
30 31 32 33 34 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 30 def get_treatments(key, split_names, attributes = nil) split_names.each_with_object({}) do |name, memo| memo.merge!(name => get_treatment(key, name, attributes)) end end |
#track ⇒ Object
57 58 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 57 def track end |