Exception: SplitIoClient::Treatments

Inherits:
NoMethodError
  • Object
show all
Defined in:
lib/engine/partitions/treatments.rb

Overview

represents the possible return values for a treatment

Constant Summary collapse

CONTROL =

Constants to represent treatment values

'control'
OFF =
'off'
ON =
'on'

Class Method Summary collapse

Class Method Details

.get_type(type) ⇒ Treatment

get the actual value for the given treatment type

Parameters:

  • type (string)

    treatment type

Returns:

  • (Treatment)

    treatment type value



18
19
20
21
22
23
24
25
26
27
# File 'lib/engine/partitions/treatments.rb', line 18

def self.get_type(type)
  case type
    when 'on'
      return ON
    when 'off', 'control'
      return CONTROL
    else # default return off
      return CONTROL
  end
end

.is_control?(treatment) ⇒ boolean

checks if the give treatment matches control type

Parameters:

  • type (string)

    treatment type

Returns:

  • (boolean)

    true if matches, false otherwise



34
35
36
# File 'lib/engine/partitions/treatments.rb', line 34

def self.is_control?(treatment)
  get_type(treatment).equal?(CONTROL) ? true : false
end