Sha256: e6f91a9ec37536e5bb5aff6b9acae5d0c39910b31f3d2a86dfdfa9d4d9c86680

Contents?: true

Size: 546 Bytes

Versions: 3

Compression:

Stored size: 546 Bytes

Contents

module WhoAmI
  class TableInfo
    def initialize(table_name)
      @table_name = table_name
    end

    attr_reader :table_name

    def columns
      @columns ||=
        begin
          columns_hash =
            ActiveRecord::Base.connection.schema_cache.columns_hash(@table_name)

          columns_hash.values.map do |column|
            TableColumnInfo.new(table_name: @table_name, column: column)
          end
        end
    end

    def indices
      @indices ||= ActiveRecord::Base.connection.indexes(@table_name)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
who_am_i-0.0.6 lib/who_am_i/table_info.rb
who_am_i-0.0.5 lib/who_am_i/table_info.rb
who_am_i-0.0.4 lib/who_am_i/table_info.rb