Class: Dynamo::Record::TaskHelpers::Scale

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamo/record/task_helpers/scale.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_name, attribute_selector, new_throughput) ⇒ Scale

Returns a new instance of Scale.



8
9
10
11
12
# File 'lib/dynamo/record/task_helpers/scale.rb', line 8

def initialize(model_name, attribute_selector, new_throughput)
  @model_name = model_name
  @attribute_selector = attribute_selector
  @new_throughput = new_throughput
end

Instance Attribute Details

#attribute_selectorObject (readonly)

Returns the value of attribute attribute_selector.



5
6
7
# File 'lib/dynamo/record/task_helpers/scale.rb', line 5

def attribute_selector
  @attribute_selector
end

#existing_throughputObject (readonly)

Returns the value of attribute existing_throughput.



6
7
8
# File 'lib/dynamo/record/task_helpers/scale.rb', line 6

def existing_throughput
  @existing_throughput
end

#migrationObject (readonly)

Returns the value of attribute migration.



6
7
8
# File 'lib/dynamo/record/task_helpers/scale.rb', line 6

def migration
  @migration
end

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/dynamo/record/task_helpers/scale.rb', line 5

def model
  @model
end

#model_nameObject (readonly)

Returns the value of attribute model_name.



6
7
8
# File 'lib/dynamo/record/task_helpers/scale.rb', line 6

def model_name
  @model_name
end

#new_throughputObject (readonly)

Returns the value of attribute new_throughput.



5
6
7
# File 'lib/dynamo/record/task_helpers/scale.rb', line 5

def new_throughput
  @new_throughput
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/dynamo/record/task_helpers/scale.rb', line 14

def run
  return description if [model_name, attribute_selector, new_throughput].any?(&:nil?)

  @model = model_name.constantize
  @migration = Aws::Record::TableMigration.new(model)
  @existing_throughput = model.provisioned_throughput

  update_throughput
  success_message
end