Sha256: ee015043699ce9e6a610cec13e3ddf2968514a868428941330727556d67f3ac8

Contents?: true

Size: 715 Bytes

Versions: 10

Compression:

Stored size: 715 Bytes

Contents

class Verdict::Conversion

  attr_reader :experiment, :subject_identifier, :goal, :created_at

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

  def subject
    experiment.fetch_subject(subject_identifier)
  end

  def assignment
    experiment.fetch_assignment(subject_identifier)
  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

10 entries across 10 versions & 1 rubygems

Version Path
verdict-0.5.0 lib/verdict/conversion.rb
verdict-0.4.1 lib/verdict/conversion.rb
verdict-0.4.0 lib/verdict/conversion.rb
verdict-0.3.2 lib/verdict/conversion.rb
verdict-0.3.1 lib/verdict/conversion.rb
verdict-0.3.0 lib/verdict/conversion.rb
verdict-0.2.1 lib/verdict/conversion.rb
verdict-0.2.0 lib/verdict/conversion.rb
verdict-0.1.1 lib/verdict/conversion.rb
verdict-0.1.0 lib/verdict/conversion.rb