Class: Rollout::FeatureState
- Inherits:
-
Object
- Object
- Rollout::FeatureState
- Defined in:
- lib/rollout/feature_state.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#percentage ⇒ Object
readonly
Returns the value of attribute percentage.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #deep_clone ⇒ Object
-
#initialize(name:, percentage:, users: [], groups: [], data: {}) ⇒ FeatureState
constructor
A new instance of FeatureState.
Constructor Details
#initialize(name:, percentage:, users: [], groups: [], data: {}) ⇒ FeatureState
Returns a new instance of FeatureState.
9 10 11 12 13 14 15 16 17 |
# File 'lib/rollout/feature_state.rb', line 9 def initialize(name:, percentage:, users: [], groups: [], data: {}) raise ArgumentError, "data must be a Hash" unless data.is_a?(Hash) @name = name.to_s.dup @percentage = percentage.to_f @users = Array(users).map { |user| user.to_s.dup } @groups = Array(groups).map { |group| group.to_s.dup } @data = canonicalize_data(data) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/rollout/feature_state.rb', line 7 def data @data end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
7 8 9 |
# File 'lib/rollout/feature_state.rb', line 7 def groups @groups end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/rollout/feature_state.rb', line 7 def name @name end |
#percentage ⇒ Object (readonly)
Returns the value of attribute percentage.
7 8 9 |
# File 'lib/rollout/feature_state.rb', line 7 def percentage @percentage end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
7 8 9 |
# File 'lib/rollout/feature_state.rb', line 7 def users @users end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rollout/feature_state.rb', line 19 def ==(other) other.is_a?(FeatureState) && name == other.name && percentage == other.percentage && users == other.users && groups == other.groups && data == other.data end |
#deep_clone ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rollout/feature_state.rb', line 28 def deep_clone self.class.new( name: name, percentage: percentage, users: users, groups: groups, data: data, ) end |