Class: Ab::Tests
- Inherits:
-
Object
show all
- Defined in:
- lib/ab/tests.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(json, id) ⇒ Tests
Returns a new instance of Tests.
13
14
15
16
17
18
19
20
|
# File 'lib/ab/tests.rb', line 13
def initialize(json, id)
json ||= {}
config = json.is_a?(Hash) ? json : JSON.parse(json)
@ab_tests = config['ab_tests'] || []
@salt = config['salt']
@bucket_count = config['bucket_count']
@id = id
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
26
27
28
|
# File 'lib/ab/tests.rb', line 26
def method_missing(name, *)
assigned_test(name.to_s) || null_test
end
|
Class Method Details
.after_picking_variant(&block) ⇒ Object
.before_picking_variant(&block) ⇒ Object
Instance Method Details
#all ⇒ Object
22
23
24
|
# File 'lib/ab/tests.rb', line 22
def all
grouped_ab_tests.keys.map { |name| [name, assigned_test(name).variant(false)] }.to_h
end
|
#respond_to_missing? ⇒ Boolean
30
31
32
|
# File 'lib/ab/tests.rb', line 30
def respond_to_missing?(*)
true
end
|