Class: Scheman::Views::Mysql::Index

Inherits:
Node
  • Object
show all
Defined in:
lib/scheman/views/mysql.rb

Instance Method Summary collapse

Methods inherited from Node

#initialize

Constructor Details

This class inherits a constructor from Scheman::Views::Mysql::Node

Instance Method Details

#columnObject

Examples:

"id"


341
342
343
# File 'lib/scheman/views/mysql.rb', line 341

def column
  @element[:column]
end

#fulltext?Boolean

Returns:

  • (Boolean)


331
332
333
# File 'lib/scheman/views/mysql.rb', line 331

def fulltext?
  @element[:type] == "fulltext"
end

#prefixObject

Examples:

"PRIMARY KEY"


347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/scheman/views/mysql.rb', line 347

def prefix
  case
  when primary_key?
    "PRIMARY KEY"
  when fulltext?
    "FULLTEXT"
  when spatial?
    "SPATIAL"
  else
    "KEY"
  end
end

#primary_key?Boolean

Returns:

  • (Boolean)


327
328
329
# File 'lib/scheman/views/mysql.rb', line 327

def primary_key?
  !!@element[:primary]
end

#spatial?Boolean

Returns:

  • (Boolean)


335
336
337
# File 'lib/scheman/views/mysql.rb', line 335

def spatial?
  @element[:type] == "spatial"
end

#to_sObject



323
324
325
# File 'lib/scheman/views/mysql.rb', line 323

def to_s
  "#{prefix} (`#{column}`)"
end