Sha256: 9be41b79b59ca3a6b9559fd93fd007e9e08b5172bc7471ccdf409f0447d1e26e

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module DataMigrations
  class Table
    delegate :connection, :to => :'ActiveRecord::Base'

    attr_reader :name

    def initialize(name)
      @name = name
    end

    def columns
      connection.columns(name)
    end

    def column_names
      columns.map(&:name)
    end

    def column(name)
      columns.detect { |column| column.name.to_s == name.to_s } || raise_column_not_found(name)
    end

    def quoted_name
      connection.quote_table_name(name)
    end

    def raise_column_not_found(name)
      raise "could not find column #{name} on #{self.name}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_migrations-0.0.1 lib/data_migrations/table.rb