Sha256: e6fc674403ac36b41e97190544d0996824778482c11382027cdd06b7d9066c04

Contents?: true

Size: 881 Bytes

Versions: 4

Compression:

Stored size: 881 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
        unless test_track_visitor.ab(feature_flag, context: self.class.name.underscore)
          raise ActionController::RoutingError, 'Not Found'
        end
      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
    RequestStore[:test_track_web_session] = test_track_session
    test_track_session.manage do
      yield
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
test_track_rails_client-4.0.0.alpha33 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha32 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha31 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha30 app/controllers/concerns/test_track/controller.rb