Class: DynamodbModel::Migration::Executor

Inherits:
Object
  • Object
show all
Includes:
DbConfig
Defined in:
lib/dynamodb_model/migration/executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DbConfig

#db, included, #namespaced_table_name

Constructor Details

#initialize(table_name, method_name, params) ⇒ Executor

Returns a new instance of Executor.



11
12
13
14
15
# File 'lib/dynamodb_model/migration/executor.rb', line 11

def initialize(table_name, method_name, params)
  @table_name = table_name
  @method_name = method_name # create_table or update_table
  @params = params
end

Instance Attribute Details

#table_nameObject

Examples:

Executor.new(:create_table, params) or
Executor.new(:update_table, params)

The params are generated frmo the dsl.params



10
11
12
# File 'lib/dynamodb_model/migration/executor.rb', line 10

def table_name
  @table_name
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dynamodb_model/migration/executor.rb', line 17

def run
  begin
    # Examples:
    #   result = db.create_table(@params)
    #   result = db.update_table(@params)
    result = db.send(@method_name, @params)

    puts "DynamoDB Table: #{@table_name} Status: #{result.table_description.table_status}"
  rescue Aws::DynamoDB::Errors::ServiceError => error
    puts "Unable to #{@method_name.to_s.gsub('_',' ')}: #{error.message}"
  end
end