Class: DecisionAgent::ABTesting::ABTestAssignment
- Inherits:
-
Object
- Object
- DecisionAgent::ABTesting::ABTestAssignment
- Defined in:
- lib/decision_agent/ab_testing/ab_test_assignment.rb
Overview
Tracks individual assignments of users/requests to A/B test variants
Instance Attribute Summary collapse
-
#ab_test_id ⇒ Object
readonly
Returns the value of attribute ab_test_id.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#decision_result ⇒ Object
readonly
Returns the value of attribute decision_result.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
-
#version_id ⇒ Object
readonly
Returns the value of attribute version_id.
Instance Method Summary collapse
-
#initialize(ab_test_id:, variant:, version_id:, **options) ⇒ ABTestAssignment
constructor
A new instance of ABTestAssignment.
-
#record_decision(decision, confidence) ⇒ Object
Update the assignment with decision results.
-
#to_h ⇒ Hash
Convert to hash representation.
Constructor Details
#initialize(ab_test_id:, variant:, version_id:, **options) ⇒ ABTestAssignment
Returns a new instance of ABTestAssignment.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 20 def initialize( ab_test_id:, variant:, version_id:, ** ) @id = [:id] @ab_test_id = ab_test_id @user_id = [:user_id] @variant = variant @version_id = version_id @timestamp = [:timestamp] || Time.now.utc @decision_result = [:decision_result] @confidence = [:confidence] @context = [:context] || {} validate! end |
Instance Attribute Details
#ab_test_id ⇒ Object (readonly)
Returns the value of attribute ab_test_id.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def ab_test_id @ab_test_id end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def confidence @confidence end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def context @context end |
#decision_result ⇒ Object (readonly)
Returns the value of attribute decision_result.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def decision_result @decision_result end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def id @id end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def @timestamp end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def user_id @user_id end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def variant @variant end |
#version_id ⇒ Object (readonly)
Returns the value of attribute version_id.
7 8 9 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 7 def version_id @version_id end |
Instance Method Details
#record_decision(decision, confidence) ⇒ Object
Update the assignment with decision results
42 43 44 45 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 42 def record_decision(decision, confidence) @decision_result = decision @confidence = confidence end |
#to_h ⇒ Hash
Convert to hash representation
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/decision_agent/ab_testing/ab_test_assignment.rb', line 49 def to_h { id: @id, ab_test_id: @ab_test_id, user_id: @user_id, variant: @variant, version_id: @version_id, timestamp: @timestamp, decision_result: @decision_result, confidence: @confidence, context: @context } end |