Class: Dynomite::Migration::Executor
- Inherits:
-
Object
- Object
- Dynomite::Migration::Executor
- Includes:
- DbConfig
- Defined in:
- lib/dynomite/migration/executor.rb
Instance Attribute Summary collapse
-
#table_name ⇒ Object
Examples: Executor.new(:create_table, params) or Executor.new(:update_table, params).
Instance Method Summary collapse
-
#initialize(table_name, method_name, params) ⇒ Executor
constructor
A new instance of Executor.
- #run ⇒ Object
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/dynomite/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_name ⇒ Object
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/dynomite/migration/executor.rb', line 10 def table_name @table_name end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dynomite/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 |