class Ryakuzu::CreateTableService
Attributes
column[R]
table[R]
type[R]
Public Class Methods
new(table, column, type)
click to toggle source
# File lib/ryakuzu/services/create_table_service.rb, line 5 def initialize(table, column, type) @table = table['name'] @column = column @type = type end
Public Instance Methods
call()
click to toggle source
# File lib/ryakuzu/services/create_table_service.rb, line 11 def call invoke_migration end
Private Instance Methods
invoke_migration()
click to toggle source
# File lib/ryakuzu/services/create_table_service.rb, line 17 def invoke_migration return if column.blank? || type.blank? || table.blank? res = column.zip(type) hash = Hash[*res.flatten] string = make_string(hash) text = "rails g model #{table.classify} #{string} && rake db:migrate" system text end
make_string(hash)
click to toggle source
# File lib/ryakuzu/services/create_table_service.rb, line 26 def make_string(hash) str = '' hash.each do |key, value| str += key + ':' + value.downcase + ' ' if value end str end