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.



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

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.



132
133
134
# File 'lib/flagsmith/engine/features/models.rb', line 132

def id
  @id
end

#multivariate_feature_optionObject (readonly)

Returns the value of attribute multivariate_feature_option.



132
133
134
# File 'lib/flagsmith/engine/features/models.rb', line 132

def multivariate_feature_option
  @multivariate_feature_option
end

#mv_fs_value_uuidObject (readonly)

Returns the value of attribute mv_fs_value_uuid.



132
133
134
# File 'lib/flagsmith/engine/features/models.rb', line 132

def mv_fs_value_uuid
  @mv_fs_value_uuid
end

#percentage_allocationObject (readonly)

Returns the value of attribute percentage_allocation.



132
133
134
# File 'lib/flagsmith/engine/features/models.rb', line 132

def percentage_allocation
  @percentage_allocation
end

Class Method Details

.build(json) ⇒ Object



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

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



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

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