Class: Kameleoon::Configuration::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/kameleoon/configuration/rule.rb

Overview

Rule is a class for new rules of feature flags

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Rule

Returns a new instance of Rule.



43
44
45
46
47
48
49
50
51
52
# File 'lib/kameleoon/configuration/rule.rb', line 43

def initialize(hash)
  @id = hash['id']
  @order = hash['order']
  @type = RuleType.from_literal(hash['type'])
  @exposition = hash['exposition']
  @respool_time = hash['respoolTime']
  @targeting_segment = Kameleoon::Targeting::Segment.new((hash['segment'])) if hash['segment']
  @segment_id = @targeting_segment != nil ? targeting_segment.id : -1
  @experiment = Experiment.from_json(hash)
end

Instance Attribute Details

#experimentObject (readonly)

Returns the value of attribute experiment.



32
33
34
# File 'lib/kameleoon/configuration/rule.rb', line 32

def experiment
  @experiment
end

#expositionObject (readonly)

Returns the value of attribute exposition.



32
33
34
# File 'lib/kameleoon/configuration/rule.rb', line 32

def exposition
  @exposition
end

#idObject (readonly)

Returns the value of attribute id.



32
33
34
# File 'lib/kameleoon/configuration/rule.rb', line 32

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



32
33
34
# File 'lib/kameleoon/configuration/rule.rb', line 32

def order
  @order
end

#respool_timeObject (readonly)

Returns the value of attribute respool_time.



32
33
34
# File 'lib/kameleoon/configuration/rule.rb', line 32

def respool_time
  @respool_time
end

#segment_idObject (readonly)

Returns the value of attribute segment_id.



32
33
34
# File 'lib/kameleoon/configuration/rule.rb', line 32

def segment_id
  @segment_id
end

#targeting_segmentObject

Returns the value of attribute targeting_segment.



33
34
35
# File 'lib/kameleoon/configuration/rule.rb', line 33

def targeting_segment
  @targeting_segment
end

#typeObject (readonly)

Returns the value of attribute type.



32
33
34
# File 'lib/kameleoon/configuration/rule.rb', line 32

def type
  @type
end

Class Method Details

.create_from_array(array) ⇒ Object



35
36
37
# File 'lib/kameleoon/configuration/rule.rb', line 35

def self.create_from_array(array)
  array&.map { |it| Rule.new(it) }
end

Instance Method Details

#experimentation_type?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/kameleoon/configuration/rule.rb', line 54

def experimentation_type?
  @type == RuleType::EXPERIMENTATION
end

#targeted_delivery_type?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/kameleoon/configuration/rule.rb', line 58

def targeted_delivery_type?
  @type == RuleType::TARGETED_DELIVERY
end

#to_sObject



39
40
41
# File 'lib/kameleoon/configuration/rule.rb', line 39

def to_s
  "Rule{id:#{@id}}"
end