Class: Verdict::Conversion
- Inherits:
-
Object
- Object
- Verdict::Conversion
- Defined in:
- lib/verdict/conversion.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#experiment ⇒ Object
readonly
Returns the value of attribute experiment.
-
#goal ⇒ Object
readonly
Returns the value of attribute goal.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #assignment ⇒ Object
-
#initialize(experiment, subject, goal, created_at = Time.now.utc) ⇒ Conversion
constructor
A new instance of Conversion.
- #subject_identifier ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(experiment, subject, goal, created_at = Time.now.utc) ⇒ Conversion
Returns a new instance of Conversion.
5 6 7 8 9 10 |
# File 'lib/verdict/conversion.rb', line 5 def initialize(experiment, subject, goal, created_at = Time.now.utc) @experiment = experiment @subject = subject @goal = goal @created_at = created_at end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/verdict/conversion.rb', line 3 def created_at @created_at end |
#experiment ⇒ Object (readonly)
Returns the value of attribute experiment.
3 4 5 |
# File 'lib/verdict/conversion.rb', line 3 def experiment @experiment end |
#goal ⇒ Object (readonly)
Returns the value of attribute goal.
3 4 5 |
# File 'lib/verdict/conversion.rb', line 3 def goal @goal end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/verdict/conversion.rb', line 3 def subject @subject end |
Instance Method Details
#as_json(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/verdict/conversion.rb', line 20 def as_json( = {}) { experiment: experiment.handle, subject: subject_identifier, goal: goal, created_at: created_at.utc.strftime('%FT%TZ') } end |
#assignment ⇒ Object
16 17 18 |
# File 'lib/verdict/conversion.rb', line 16 def assignment experiment.lookup(subject) end |
#subject_identifier ⇒ Object
12 13 14 |
# File 'lib/verdict/conversion.rb', line 12 def subject_identifier experiment.retrieve_subject_identifier(subject) end |
#to_json(options = {}) ⇒ Object
29 30 31 |
# File 'lib/verdict/conversion.rb', line 29 def to_json( = {}) as_json().to_json end |