Sha256: 07225a9ec6cbb3b86fceec2593823134ab8c261aa73b564d6847b7ee1c6af3c3

Contents?: true

Size: 802 Bytes

Versions: 13

Compression:

Stored size: 802 Bytes

Contents

class KnjDB_mysql::Indexes
  def initialize(args)
    @args = args
  end
end

class KnjDB_mysql::Indexes::Index
  attr_reader :columns
  
  def initialize(args)
    @args = args
    @columns = []
  end
  
  def name
    return @args[:data][:Key_name]
  end
  
  def table
    return @args[:db].tables[@args[:table_name]]
  end
  
  def drop
    sql = "DROP INDEX `#{self.name}` ON `#{self.table.name}`"
    @args[:db].query(sql)
  end
  
  def data
    return {
      "name" => name,
      "columns" => @columns
    }
  end
  
  #Returns true if the index is a unique-index.
  def unique?
    if @args[:data][:Index_type] == "UNIQUE"
      return true
    else
      return false
    end
  end
  
  #Inspect crashes if this is not present? - knj.
  def to_s
    return "#<#{self.class.name}>"
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
knjrbfw-0.0.21 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.20 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.19 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.18 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.17 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.16 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.15 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.14 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.13 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.12 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.11 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.10 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
knjrbfw-0.0.9 lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb