Sha256: ef5090978724d8e137a77709f73c7f1592b738d4595e1480c1dd11d260ac1d57

Contents?: true

Size: 873 Bytes

Versions: 22

Compression:

Stored size: 873 Bytes

Contents

module SplitIoClient
  #
  # represents the possible return values for a treatment
  #
  class Treatments < NoMethodError
    # Constants to represent treatment values
    CONTROL = 'control'
    OFF = 'off'
    ON = 'on'

    # get the actual value for the given treatment type
    #
    # @param type [string] treatment type
    #
    # @return [Treatment] treatment type value
    def self.get_type(type)
      case type
        when 'on'
          return ON
        when 'off', 'control'
          return CONTROL
        else # default return off
          return CONTROL
      end
    end

    # checks if the give treatment matches control type
    #
    # @param type [string] treatment type
    #
    # @return [boolean] true if matches, false otherwise
    def self.is_control?(treatment)
      get_type(treatment).equal?(CONTROL) ? true : false
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
splitclient-rb-4.1.0 lib/engine/partitions/treatments.rb
splitclient-rb-4.1.0.pre.rc2 lib/engine/partitions/treatments.rb
splitclient-rb-4.1.0.pre.rc1 lib/engine/partitions/treatments.rb
splitclient-rb-4.0.0 lib/engine/partitions/treatments.rb
splitclient-rb-4.0.0.pre.rc1 lib/engine/partitions/treatments.rb
splitclient-rb-3.3.0 lib/engine/partitions/treatments.rb
splitclient-rb-3.3.0.pre.rc1 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.4 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.4.pre.rc5 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.4.pre.rc4 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.4.pre.rc3 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.4.pre.rc2 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.4.pre.rc1 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.3 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.3.pre.rc1 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.2 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.1 lib/engine/partitions/treatments.rb
splitclient-rb-3.2.0 lib/engine/partitions/treatments.rb
splitclient-rb-3.1.3 lib/engine/partitions/treatments.rb
splitclient-rb-3.1.3.pre.rc3 lib/engine/partitions/treatments.rb