Sha256: 94a67cf448f11fff35ee0b66b80d724d673370751dacca8b701428a6b54ded4c

Contents?: true

Size: 852 Bytes

Versions: 2

Compression:

Stored size: 852 Bytes

Contents

module TestTrack::Controller
  extend ActiveSupport::Concern

  included do
    class_attribute :test_track_identity

    helper_method :test_track_session, :test_track_visitor
    helper TestTrack::ApplicationHelper
    around_action :manage_test_track_session
  end

  class_methods do
    def require_feature_flag(feature_flag, *args)
      before_action(*args) do
        raise ActionController::RoutingError, 'Not Found' unless test_track_visitor.ab(feature_flag, context: self.class.name.underscore)
      end
    end
  end

  private

  def test_track_session
    @test_track_session ||= TestTrack::WebSession.new(self)
  end

  def test_track_visitor
    test_track_session.visitor_dsl
  end

  def manage_test_track_session(&block)
    RequestStore[:test_track_web_session] = test_track_session
    test_track_session.manage(&block)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
test_track_rails_client-7.1.2 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-7.1.1 app/controllers/concerns/test_track/controller.rb