Sha256: ffb199a9fa6127515b65f562798a438bb99895e92d8f5ca17c3a2df75a0e8594

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

class Dynomite::Migration
  class Executor
    include Dynomite::DbConfig

    # Examples:
    #  Executor.new(:create_table, params) or
    #  Executor.new(:update_table, params)
    #
    # The params are generated frmo the dsl.params
    attr_accessor :table_name
    def initialize(table_name, method_name, params)
      @table_name = table_name
      @method_name = method_name # create_table or update_table
      @params = params
    end

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

        # Leaving this verbose output in here until this DSL is more hardened to help debug
        unless ENV['DYNOMITE_ENV'] == 'test'
          puts "Calling #{@method_name} with params:"
          pp @params
        end

        return if ENV['DYNOMITE_DRY'] # dry run flag
        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}".colorize(:red)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
dynomite-1.2.4 lib/dynomite/migration/executor.rb
dynomite-1.2.3 lib/dynomite/migration/executor.rb
dynomite-1.2.2 lib/dynomite/migration/executor.rb
dynomite-1.2.1 lib/dynomite/migration/executor.rb
dynomite-1.2.0 lib/dynomite/migration/executor.rb
dynomite-1.1.1 lib/dynomite/migration/executor.rb
jets-1.4.10 vendor/dynomite/lib/dynomite/migration/executor.rb
dynomite-1.1.0 lib/dynomite/migration/executor.rb