Class: ScalingWorkload

Inherits:
Workload
  • Object
show all
Defined in:
app/models/scaling_workload.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object


12
13
14
15
16
17
18
# File 'app/models/scaling_workload.rb', line 12

def as_json(options={})
  hash = {}
  hash[:id] = self.id
  hash[:scale_ingredient] = self.scale_ingredient
  hash[:ingredient_id] = self.ingredient_id
  hash
end

#to_constraint(num_users) ⇒ Object


5
6
7
8
9
10
# File 'app/models/scaling_workload.rb', line 5

def to_constraint(num_users)
  self.ingredient.scaling_constraint.destroy if self.ingredient.scaling_constraint.present?
  self.ingredient.scaling_constraint = ScalingConstraint.create(
    max_num_instances: scale_ingredient ? 0 : 1
  )
end