Class: Flagsmith::Engine::Features::MultivariateStateValue

Inherits:
Object
  • Object
show all
Defined in:
lib/flagsmith/engine/features/models.rb

Overview

MultivariateFeatureStateValueModel

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, multivariate_feature_option:, percentage_allocation:, mv_fs_value_uuid: SecureRandom.uuid) ⇒ MultivariateStateValue

Returns a new instance of MultivariateStateValue.



136
137
138
139
140
141
# File 'lib/flagsmith/engine/features/models.rb', line 136

def initialize(id:, multivariate_feature_option:, percentage_allocation:, mv_fs_value_uuid: SecureRandom.uuid)
  @id = id
  @percentage_allocation = percentage_allocation
  @multivariate_feature_option = multivariate_feature_option
  @mv_fs_value_uuid = mv_fs_value_uuid
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



134
135
136
# File 'lib/flagsmith/engine/features/models.rb', line 134

def id
  @id
end

#multivariate_feature_optionObject (readonly)

Returns the value of attribute multivariate_feature_option.



134
135
136
# File 'lib/flagsmith/engine/features/models.rb', line 134

def multivariate_feature_option
  @multivariate_feature_option
end

#mv_fs_value_uuidObject (readonly)

Returns the value of attribute mv_fs_value_uuid.



134
135
136
# File 'lib/flagsmith/engine/features/models.rb', line 134

def mv_fs_value_uuid
  @mv_fs_value_uuid
end

#percentage_allocationObject (readonly)

Returns the value of attribute percentage_allocation.



134
135
136
# File 'lib/flagsmith/engine/features/models.rb', line 134

def percentage_allocation
  @percentage_allocation
end

Class Method Details

.build(json) ⇒ Object



154
155
156
157
158
159
# File 'lib/flagsmith/engine/features/models.rb', line 154

def build(json)
  new(
    **json.slice(:id, :percentage_allocation, :mv_fs_value_uuid)
          .merge(multivariate_feature_option: MultivariateOption.build(json[:multivariate_feature_option]))
  )
end

Instance Method Details

#<=>(other) ⇒ Object



143
144
145
146
147
148
149
150
151
# File 'lib/flagsmith/engine/features/models.rb', line 143

def <=>(other)
  return false if other.nil?

  if !id.nil? && !other.id.nil?
    id - other.id
  else
    mv_fs_value_uuid <=> other.mv_fs_value_uuid
  end
end