Class: KnjDB_mysql::Indexes::Index
- Defined in:
- lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
Instance Method Summary collapse
- #data ⇒ Object
- #drop ⇒ Object
-
#initialize(args) ⇒ Index
constructor
A new instance of Index.
- #name ⇒ Object
- #table ⇒ Object
-
#to_s ⇒ Object
Inspect crashes if this is not present? - knj.
-
#unique? ⇒ Boolean
Returns true if the index is a unique-index.
Constructor Details
#initialize(args) ⇒ Index
Returns a new instance of Index.
10 11 12 13 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 10 def initialize(args) @args = args @columns = [] end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
8 9 10 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 8 def columns @columns end |
Instance Method Details
#data ⇒ Object
28 29 30 31 32 33 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 28 def data return { "name" => name, "columns" => @columns } end |
#drop ⇒ Object
23 24 25 26 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 23 def drop sql = "DROP INDEX `#{self.name}` ON `#{self.table.name}`" @args[:db].query(sql) end |
#name ⇒ Object
15 16 17 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 15 def name return @args[:data][:Key_name] end |
#table ⇒ Object
19 20 21 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 19 def table return @args[:db].tables[@args[:table_name]] end |
#to_s ⇒ Object
Inspect crashes if this is not present? - knj.
45 46 47 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 45 def to_s return "#<#{self.class.name}>" end |
#unique? ⇒ Boolean
Returns true if the index is a unique-index.
36 37 38 39 40 41 42 |
# File 'lib/knj/knjdb/drivers/mysql/knjdb_mysql_indexes.rb', line 36 def unique? if @args[:data][:Index_type] == "UNIQUE" return true else return false end end |