Class: MigrationDefs::MigrationClass
- Inherits:
-
Object
- Object
- MigrationDefs::MigrationClass
- Defined in:
- lib/migration_defs.rb
Instance Attribute Summary collapse
-
#methods ⇒ Object
Returns the value of attribute methods.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #add_method(name) ⇒ Object
- #get_str ⇒ Object
-
#initialize(name, parent_name = nil) ⇒ MigrationClass
constructor
A new instance of MigrationClass.
- #parse_from_params(parse_params) ⇒ Object
Constructor Details
#initialize(name, parent_name = nil) ⇒ MigrationClass
Returns a new instance of MigrationClass.
45 46 47 48 49 |
# File 'lib/migration_defs.rb', line 45 def initialize(name, parent_name = nil) @name = name @parent = parent_name @methods = Hash.new end |
Instance Attribute Details
#methods ⇒ Object
Returns the value of attribute methods.
43 44 45 |
# File 'lib/migration_defs.rb', line 43 def methods @methods end |
#name ⇒ Object
Returns the value of attribute name.
43 44 45 |
# File 'lib/migration_defs.rb', line 43 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
43 44 45 |
# File 'lib/migration_defs.rb', line 43 def parent @parent end |
Instance Method Details
#add_method(name) ⇒ Object
64 65 66 |
# File 'lib/migration_defs.rb', line 64 def add_method(name) @methods[name] = MigrationMethod.new(name) end |
#get_str ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/migration_defs.rb', line 68 def get_str return if @name.nil? result = 'class ' + @name + (@parent.nil? ? '' : '< ' + @parent) + "\n" @methods.each do |key, val| result += val.get_str end result += "end\n" end |
#parse_from_params(parse_params) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/migration_defs.rb', line 51 def parse_from_params(parse_params) return '' if parse_params[:methods].nil? parse_params[:methods].each do |key, val| add_method(key) if val[:enable] == 'true' end parse_params[:methods].each do |p_key, p_val|#not DRY @methods.each do |m_key, m_val| m_val.parse_from_params(p_val) if p_key == m_key end end end |