Sha256: 2e375ea8bcd045985faf83d927af5957559e64ea305361828bff4faf7d05bd6a

Contents?: true

Size: 664 Bytes

Versions: 17

Compression:

Stored size: 664 Bytes

Contents

class Verdict::Conversion

  attr_reader :experiment, :subject, :goal, :created_at

  def initialize(experiment, subject, goal, created_at = Time.now.utc)
    @experiment = experiment
    @subject = subject
    @goal = goal
    @created_at = created_at
  end

  def subject_identifier
    experiment.retrieve_subject_identifier(subject)
  end

  def assignment
    experiment.lookup(subject)
  end

  def as_json(options = {})
    {
      experiment: experiment.handle,
      subject:    subject_identifier,
      goal:       goal,
      created_at: created_at.utc.strftime('%FT%TZ')
    }
  end

  def to_json(options = {})
    as_json(options).to_json
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
verdict-0.16.1 lib/verdict/conversion.rb
verdict-0.16.0 lib/verdict/conversion.rb
verdict-0.15.2 lib/verdict/conversion.rb
verdict-0.15.1 lib/verdict/conversion.rb
verdict-0.15.0 lib/verdict/conversion.rb
verdict-0.14.0 lib/verdict/conversion.rb
verdict-0.13.0 lib/verdict/conversion.rb
verdict-0.12.0 lib/verdict/conversion.rb
verdict-0.11.0 lib/verdict/conversion.rb
verdict-0.10.0 lib/verdict/conversion.rb
verdict-0.9.0 lib/verdict/conversion.rb
verdict-0.8.0 lib/verdict/conversion.rb
verdict-0.7.0 lib/verdict/conversion.rb
verdict-0.6.3 lib/verdict/conversion.rb
verdict-0.6.2 lib/verdict/conversion.rb
verdict-0.6.1 lib/verdict/conversion.rb
verdict-0.6.0 lib/verdict/conversion.rb