Sha256: ed053ac43f1b93ae39f80c31082b08c0a27870fad9f14aa34f574a6f38ce7f78

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

module OptimizelyServerSide

  class Variation

    attr_reader :hsh

    def initialize(variation_key)
      @variation_key = variation_key
      @hsh = {}
    end

    # Variation one of experiment
    def variation_one(key)
      @hsh[key] = yield
    end

    # Variation two of experiment
    def variation_two(key)
      @hsh[key] = yield
    end

    def variation_default(key)
      @hsh[key] = yield
    end

    # Variation three of experiment
    def variation_three(key)
      @hsh[key] = yield
    end

    # Select which variation to be picked up
    def compute
      @hsh.select do |key,value|
        key == @variation_key
      end.values[0]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
optimizely_server_side-0.0.3 lib/optimizely_server_side/variation.rb