Sha256: 7df8eee68bbf9a3ad29b619d39c87c6481348198f7dba59966e0dee332133cd9

Contents?: true

Size: 859 Bytes

Versions: 11

Compression:

Stored size: 859 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
    RequestStore[:test_track_web_session] = test_track_session
    test_track_session.manage do
      yield
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
test_track_rails_client-7.0.0 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-6.0.0 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-5.0.1 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-5.0.0 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.2 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.1 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.rc3 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.rc2 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha35 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha34 app/controllers/concerns/test_track/controller.rb