Class: FeatureHub::Sdk::Impl::RolloutStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_hub/sdk/impl/rollout_holders.rb

Overview

represents a raw rollout strategy inside a feature

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strategy) ⇒ RolloutStrategy

Returns a new instance of RolloutStrategy.



93
94
95
96
97
98
99
100
101
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 93

def initialize(strategy)
  @strategy = strategy
  @attributes = (strategy["attributes"] || []).map { |attr| RolloutStrategyAttribute.new(attr) }
  @id = strategy["id"]
  @name = strategy["name"]
  @percentage = (strategy["percentage"] || "0").to_i
  @percentage_attributes = (strategy["percentageAttributes"] || [])
  @value = strategy["value"]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



91
92
93
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 91

def attributes
  @attributes
end

#idObject (readonly)

Returns the value of attribute id.



91
92
93
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 91

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



91
92
93
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 91

def name
  @name
end

#percentageObject (readonly)

Returns the value of attribute percentage.



91
92
93
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 91

def percentage
  @percentage
end

#percentage_attributesObject (readonly)

Returns the value of attribute percentage_attributes.



91
92
93
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 91

def percentage_attributes
  @percentage_attributes
end

#valueObject (readonly)

Returns the value of attribute value.



91
92
93
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 91

def value
  @value
end

Instance Method Details

#attributes?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 107

def attributes?
  !@attributes.empty?
end

#percentage_attributes?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 103

def percentage_attributes?
  !@percentage_attributes.empty?
end

#to_sObject



111
112
113
114
# File 'lib/feature_hub/sdk/impl/rollout_holders.rb', line 111

def to_s
  "id: #{@id}, name: #{@name}, percentage: #{@percentage}, percentage_attrs: #{@percentage_attributes}, " \
    "value: #{@value}, attributes: [#{@attributes.map(&:to_s).join(",")}]"
end