Class: MigrationDefs::AddIndexFunc
- Inherits:
-
AbstractMigrationClass
- Object
- AbstractMigrationClass
- MigrationDefs::AddIndexFunc
- Defined in:
- lib/migration_defs.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#option ⇒ Object
Returns the value of attribute option.
Instance Method Summary collapse
- #get_str ⇒ Object
-
#initialize(name) ⇒ AddIndexFunc
constructor
A new instance of AddIndexFunc.
- #parse_from_params(parse_params) ⇒ Object
- #set_columns(val) ⇒ Object
Constructor Details
#initialize(name) ⇒ AddIndexFunc
Returns a new instance of AddIndexFunc.
509 510 511 512 513 |
# File 'lib/migration_defs.rb', line 509 def initialize(name) @name = name @columns = '[]' @option = IndexOption.new end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
507 508 509 |
# File 'lib/migration_defs.rb', line 507 def columns @columns end |
#name ⇒ Object
Returns the value of attribute name.
507 508 509 |
# File 'lib/migration_defs.rb', line 507 def name @name end |
#option ⇒ Object
Returns the value of attribute option.
507 508 509 |
# File 'lib/migration_defs.rb', line 507 def option @option end |
Instance Method Details
#get_str ⇒ Object
526 527 528 529 530 531 532 533 |
# File 'lib/migration_defs.rb', line 526 def get_str result = 'add_index ' result += " :#{@name}" if !@name.nil? && !@name.blank? result += ", #{@columns}" if !@columns.nil? && !@columns.blank? result += " #{@option.get_str}" result += "\n" result end |
#parse_from_params(parse_params) ⇒ Object
519 520 521 522 523 524 |
# File 'lib/migration_defs.rb', line 519 def parse_from_params(parse_params) @columns = set_columns(parse_params[:columns]) @option.set_option 'name', parse_params[:index_name] @option.set_option 'unique', parse_params[:unique] @option.set_option 'length', parse_params[:length] end |
#set_columns(val) ⇒ Object
515 516 517 |
# File 'lib/migration_defs.rb', line 515 def set_columns(val) @columns = val end |