Class: GovukAbTesting::AbTest

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_ab_testing/ab_test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ab_test_name, dimension:) ⇒ AbTest

for this specific A/B test

Parameters:

  • request (String)

    the name of the A/B test

  • dimension (Integer)

    the dimension registered with Google Analytics



8
9
10
11
# File 'lib/govuk_ab_testing/ab_test.rb', line 8

def initialize(ab_test_name, dimension:)
  @ab_test_name = ab_test_name
  @dimension = dimension
end

Instance Attribute Details

#ab_test_nameObject (readonly)

Returns the value of attribute ab_test_name.



3
4
5
# File 'lib/govuk_ab_testing/ab_test.rb', line 3

def ab_test_name
  @ab_test_name
end

Instance Method Details

#meta_tag_nameObject



28
29
30
# File 'lib/govuk_ab_testing/ab_test.rb', line 28

def meta_tag_name
  ab_test_name
end

#request_headerObject

Internal name of the header



20
21
22
# File 'lib/govuk_ab_testing/ab_test.rb', line 20

def request_header
  "HTTP_GOVUK_ABTEST_#{ab_test_name.upcase}"
end

#requested_variant(request_headers) ⇒ Object

the controller.

Parameters:

  • request (ActionDispatch::Http::Headers)

    the ‘request.headers` in



15
16
17
# File 'lib/govuk_ab_testing/ab_test.rb', line 15

def requested_variant(request_headers)
  RequestedVariant.new(self, request_headers, @dimension)
end

#response_headerObject



24
25
26
# File 'lib/govuk_ab_testing/ab_test.rb', line 24

def response_header
  "GOVUK-ABTest-#{meta_tag_name}"
end