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(key, split_name, attributes = nil) ⇒ string
obtains the treatment for a given feature.
-
#get_treatment_with_config(key, split_name, attributes = nil) ⇒ hash
obtains the treatment and config for a given feature.
-
#get_treatments(key, split_names, attributes = nil) ⇒ hash
obtains the treatments for a given set of features.
-
#get_treatments_with_config(key, split_names, attributes = nil) ⇒ hash
obtains the treatments and configs for a given set of features.
-
#initialize(splits_file, config, 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, config, reload_rate = nil) ⇒ LocalhostSplitIoClient
Creates a new split client instance that reads from the given splits file
16 17 18 19 20 21 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 16 def initialize(splits_file, config, reload_rate = nil) @localhost_mode = true @localhost_mode_features = [] load_localhost_mode_features(splits_file, reload_rate) @config = config 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
27 28 29 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 27 def self.sdk_version 'ruby-'+SplitIoClient::VERSION end |
Instance Method Details
#get_treatment(key, split_name, attributes = nil) ⇒ string
obtains the treatment for a given feature
67 68 69 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 67 def get_treatment(key, split_name, attributes = nil) get_localhost_treatment(key, split_name, attributes)[:treatment] end |
#get_treatment_with_config(key, split_name, attributes = nil) ⇒ hash
obtains the treatment and config for a given feature
79 80 81 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 79 def get_treatment_with_config(key, split_name, attributes = nil) get_localhost_treatment(key, split_name, attributes, 'get_treatment_with_config') end |
#get_treatments(key, split_names, attributes = nil) ⇒ hash
obtains the treatments for a given set of features
51 52 53 54 55 56 57 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 51 def get_treatments(key, split_names, attributes = nil) treatments = get_localhost_treatments(key, split_names, attributes) return treatments if treatments.nil? keys = treatments.keys treats = treatments.map { |_,t| t[:treatment] } Hash[keys.zip(treats)] end |
#get_treatments_with_config(key, split_names, attributes = nil) ⇒ hash
obtains the treatments and configs for a given set of features
39 40 41 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 39 def get_treatments_with_config(key, split_names, attributes = nil) get_localhost_treatments(key, split_names, attributes, 'get_treatments_with_config') end |
#track ⇒ Object
83 84 |
# File 'lib/splitclient-rb/clients/localhost_split_client.rb', line 83 def track end |