Sha256: 05602d509943b52bff3993c816f00880d22e5c011fd24332a1f5112553acb2bc

Contents?: true

Size: 879 Bytes

Versions: 4

Compression:

Stored size: 879 Bytes

Contents

module GovukAbTesting
  class AbTest
    attr_reader :ab_test_name
    attr_reader :dimension

    alias_method :name, :ab_test_name

    # @param request [String] the name of the A/B test
    # @param dimension [Integer] the dimension registered with Google Analytics
    # for this specific A/B test
    def initialize(ab_test_name, dimension:)
      @ab_test_name = ab_test_name
      @dimension = dimension
    end

    # @param request [ActionDispatch::Http::Headers] the `request.headers` in
    # the controller.
    def requested_variant(request_headers)
      RequestedVariant.new(self, request_headers, @dimension)
    end

    # Internal name of the header
    def request_header
      "HTTP_GOVUK_ABTEST_#{ab_test_name.upcase}"
    end

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

    def meta_tag_name
      ab_test_name
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govuk_ab_testing-2.3.1 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-2.3.0 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-2.2.0 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-2.1.0 lib/govuk_ab_testing/ab_test.rb