Class: MigrationDefs::MigrationMethod
- Inherits:
-
AbstractMigrationClass
- Object
- AbstractMigrationClass
- MigrationDefs::MigrationMethod
- Defined in:
- lib/migration_defs.rb
Instance Attribute Summary collapse
-
#funcs ⇒ Object
Returns the value of attribute funcs.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #add_func(name, func_name, *func_options) ⇒ Object
- #get_str ⇒ Object
-
#initialize(name) ⇒ MigrationMethod
constructor
A new instance of MigrationMethod.
- #parse_from_params(parse_params) ⇒ Object
Constructor Details
#initialize(name) ⇒ MigrationMethod
Returns a new instance of MigrationMethod.
87 88 89 90 91 92 |
# File 'lib/migration_defs.rb', line 87 def initialize(name) return nil if !MethodName.include? name @name = name @funcs = Array.new end |
Instance Attribute Details
#funcs ⇒ Object
Returns the value of attribute funcs.
85 86 87 |
# File 'lib/migration_defs.rb', line 85 def funcs @funcs end |
#name ⇒ Object
Returns the value of attribute name.
85 86 87 |
# File 'lib/migration_defs.rb', line 85 def name @name end |
Instance Method Details
#add_func(name, func_name, *func_options) ⇒ Object
94 95 96 |
# File 'lib/migration_defs.rb', line 94 def add_func(name, func_name, *) @funcs << FuncFactory::get(name, func_name, ) end |
#get_str ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/migration_defs.rb', line 113 def get_str result = "def #{@name}\n" @funcs.each do |func| result += func.get_str if !func.nil? end result += "end\n" end |
#parse_from_params(parse_params) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/migration_defs.rb', line 98 def parse_from_params(parse_params) return '' if parse_params[:funcs].nil? parse_params[:funcs].each do |val| add_func(val[:name], val[:table_name]) if val[:delete] != 'true' end index = 0 parse_params[:funcs].each do |val|#not DRY if val[:delete] != 'true' @funcs[index].parse_from_params(val) index += 1 end end end |