Sha256: 2f64e32068011b0e97ca4a48dc81e8647a3142e8fe36f90fd1785aa5bdff7265

Contents?: true

Size: 700 Bytes

Versions: 13

Compression:

Stored size: 700 Bytes

Contents

class TestTrack::Assignment
  include TestTrack::RequiredOptions

  attr_accessor :context
  attr_reader :visitor, :split_name
  attr_writer :variant

  def initialize(opts = {})
    @visitor = require_option!(opts, :visitor)
    @split_name = require_option!(opts, :split_name).to_s
    raise ArgumentError, "unknown opts: #{opts.keys.to_sentence}" if opts.present?
  end

  def variant
    @variant ||= _variant
  end

  def unsynced?
    true
  end

  def feature_gate?
    split_name.end_with?('_enabled')
  end

  private

  def _variant
    return if visitor.offline?

    variant = TestTrack::VariantCalculator.new(visitor: visitor, split_name: split_name).variant
    variant&.to_s
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
test_track_rails_client-7.1.2 app/models/test_track/assignment.rb
test_track_rails_client-7.1.1 app/models/test_track/assignment.rb
test_track_rails_client-7.0.0 app/models/test_track/assignment.rb
test_track_rails_client-6.0.0 app/models/test_track/assignment.rb
test_track_rails_client-5.0.1 app/models/test_track/assignment.rb
test_track_rails_client-5.0.0 app/models/test_track/assignment.rb
test_track_rails_client-4.0.2 app/models/test_track/assignment.rb
test_track_rails_client-4.0.1 app/models/test_track/assignment.rb
test_track_rails_client-4.0.0 app/models/test_track/assignment.rb
test_track_rails_client-4.0.0.rc3 app/models/test_track/assignment.rb
test_track_rails_client-4.0.0.rc2 app/models/test_track/assignment.rb
test_track_rails_client-4.0.0.alpha35 app/models/test_track/assignment.rb
test_track_rails_client-4.0.0.alpha34 app/models/test_track/assignment.rb