Class: MigrationDefs::IndexOption
- Inherits:
-
AbstractMigrationClass
- Object
- AbstractMigrationClass
- MigrationDefs::IndexOption
- Defined in:
- lib/migration_defs.rb
Constant Summary collapse
- Description =
{ 'name' => 'インデックスの名前', 'unique' => 'ユニークなインデックス', 'length' => 'インデックスに含まれるカラムの長さ', }
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#name ⇒ Object
Returns the value of attribute name.
-
#unique ⇒ Object
Returns the value of attribute unique.
Instance Method Summary collapse
- #get_str ⇒ Object
-
#initialize(name = "''", unique = nil, length = nil) ⇒ IndexOption
constructor
A new instance of IndexOption.
- #set_option(key, val) ⇒ Object
Constructor Details
#initialize(name = "''", unique = nil, length = nil) ⇒ IndexOption
Returns a new instance of IndexOption.
480 481 482 483 484 |
# File 'lib/migration_defs.rb', line 480 def initialize(name = "''", unique = nil, length = nil) @name = name @unique = unique @length = length end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
472 473 474 |
# File 'lib/migration_defs.rb', line 472 def length @length end |
#name ⇒ Object
Returns the value of attribute name.
472 473 474 |
# File 'lib/migration_defs.rb', line 472 def name @name end |
#unique ⇒ Object
Returns the value of attribute unique.
472 473 474 |
# File 'lib/migration_defs.rb', line 472 def unique @unique end |
Instance Method Details
#get_str ⇒ Object
497 498 499 500 501 502 503 |
# File 'lib/migration_defs.rb', line 497 def get_str result = '' result += ", :name => #{@name}" if !@name.nil? && !@name.blank? result += ", :unique => #{@unique.to_s}" if !@unique.nil? result += ", :length => #{@length.to_s}" if !@length.nil? result end |
#set_option(key, val) ⇒ Object
486 487 488 489 490 491 492 493 494 495 |
# File 'lib/migration_defs.rb', line 486 def set_option(key, val) case key when 'name' @name = val when 'unique' @unique = (val == 'true') when 'length' @length = !val.blank? ? val.to_i : nil end end |