Sha256: 4344ab43f9354b7a81a4907c58a69e8a51e5efa3c3abc0b04e9b73829341d8c5

Contents?: true

Size: 874 Bytes

Versions: 15

Compression:

Stored size: 874 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::Session.new(self)
  end

  def test_track_visitor
    test_track_session.visitor_dsl
  end

  def manage_test_track_session
    RequestStore[:test_track_session] = test_track_session
    test_track_session.manage do
      yield
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
test_track_rails_client-4.0.0.alpha29 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha28 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha27 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha26 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha25 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha24 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha23 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha22 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha21 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha20 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha19 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha18 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha17 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha16 app/controllers/concerns/test_track/controller.rb
test_track_rails_client-4.0.0.alpha15 app/controllers/concerns/test_track/controller.rb