Class: Gxapi::Base
- Inherits:
-
Object
- Object
- Gxapi::Base
- Defined in:
- lib/gxapi/base.rb
Constant Summary collapse
- TIMEOUT =
2.0
Instance Attribute Summary collapse
-
#user_key ⇒ Object
readonly
Returns the value of attribute user_key.
Instance Method Summary collapse
-
#env ⇒ Object
get the env.
-
#get_experiments ⇒ Array<Ostruct>
get all experiments.
-
#get_variant(experiment_name, override = nil) ⇒ Celluloid::Future
return a variant value.
-
#initialize(user_key) ⇒ Base
constructor
the cache_key.
-
#reload_experiments ⇒ Boolean
reload the experiment cache from the remote.
Constructor Details
#initialize(user_key) ⇒ Base
the cache_key
11 12 13 14 |
# File 'lib/gxapi/base.rb', line 11 def initialize(user_key) @user_key = user_key @interface = GoogleAnalytics.new end |
Instance Attribute Details
#user_key ⇒ Object (readonly)
Returns the value of attribute user_key.
6 7 8 |
# File 'lib/gxapi/base.rb', line 6 def user_key @user_key end |
Instance Method Details
#get_experiments ⇒ Array<Ostruct>
get all experiments
25 26 27 |
# File 'lib/gxapi/base.rb', line 25 def get_experiments @interface.get_experiments end |
#get_variant(experiment_name, override = nil) ⇒ Celluloid::Future
return a variant value
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gxapi/base.rb', line 38 def get_variant(experiment_name, override = nil) Celluloid::Future.new do # allows us to override and get back a variant # easily that conforms to the api if override.nil? self.get_variant_value(experiment_name) else Ostruct.new(self.default_values.merge(name: override)) end end end |
#reload_experiments ⇒ Boolean
reload the experiment cache from the remote
54 55 56 57 |
# File 'lib/gxapi/base.rb', line 54 def reload_experiments @interface.reload_experiments true end |