Sha256: e07fe8c83ca61f78591cfd0380f71c5c7d147bc440520a5b25994ebee9a8e2d1

Contents?: true

Size: 790 Bytes

Versions: 6

Compression:

Stored size: 790 Bytes

Contents

module GovukAbTesting
  class AbTest
    attr_reader :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 [ApplicationController::Request] the `request` in the
    # controller.
    def requested_variant(request)
      RequestedVariant.new(self, request, @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

6 entries across 6 versions & 1 rubygems

Version Path
govuk_ab_testing-0.2.0 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-0.1.5 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-0.1.4 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-0.1.3 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-0.1.2 lib/govuk_ab_testing/ab_test.rb
govuk_ab_testing-0.1.1 lib/govuk_ab_testing/ab_test.rb