Class: Optimizely::Decide::OptimizelyDecision

Inherits:
Object
  • Object
show all
Defined in:
lib/optimizely/decide/optimizely_decision.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variation_key: nil, enabled: nil, variables: nil, rule_key: nil, flag_key: nil, user_context: nil, reasons: nil) ⇒ OptimizelyDecision

Returns a new instance of OptimizelyDecision.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/optimizely/decide/optimizely_decision.rb', line 25

def initialize(
  variation_key: nil,
  enabled: nil,
  variables: nil,
  rule_key: nil,
  flag_key: nil,
  user_context: nil,
  reasons: nil
)
  @variation_key = variation_key
  @enabled = enabled || false
  @variables = variables || {}
  @rule_key = rule_key
  @flag_key = flag_key
  @user_context = user_context
  @reasons = reasons || []
end

Instance Attribute Details

#enabledObject (readonly)

Returns the value of attribute enabled.



23
24
25
# File 'lib/optimizely/decide/optimizely_decision.rb', line 23

def enabled
  @enabled
end

#flag_keyObject (readonly)

Returns the value of attribute flag_key.



23
24
25
# File 'lib/optimizely/decide/optimizely_decision.rb', line 23

def flag_key
  @flag_key
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



23
24
25
# File 'lib/optimizely/decide/optimizely_decision.rb', line 23

def reasons
  @reasons
end

#rule_keyObject (readonly)

Returns the value of attribute rule_key.



23
24
25
# File 'lib/optimizely/decide/optimizely_decision.rb', line 23

def rule_key
  @rule_key
end

#user_contextObject (readonly)

Returns the value of attribute user_context.



23
24
25
# File 'lib/optimizely/decide/optimizely_decision.rb', line 23

def user_context
  @user_context
end

#variablesObject (readonly)

Returns the value of attribute variables.



23
24
25
# File 'lib/optimizely/decide/optimizely_decision.rb', line 23

def variables
  @variables
end

#variation_keyObject (readonly)

Returns the value of attribute variation_key.



23
24
25
# File 'lib/optimizely/decide/optimizely_decision.rb', line 23

def variation_key
  @variation_key
end

Instance Method Details

#as_jsonObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/optimizely/decide/optimizely_decision.rb', line 43

def as_json
  {
    variation_key: @variation_key,
    enabled: @enabled,
    variables: @variables,
    rule_key: @rule_key,
    flag_key: @flag_key,
    user_context: @user_context.as_json,
    reasons: @reasons
  }
end

#to_json(*args) ⇒ Object



55
56
57
# File 'lib/optimizely/decide/optimizely_decision.rb', line 55

def to_json(*args)
  as_json.to_json(*args)
end