Module: Database::Generators

Included in:
Myrails::Myrails
Defined in:
lib/myrails/modules/database_generator.rb

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/myrails/modules/database_generator.rb', line 3

def self.included(thor)
  thor.class_eval do
    
    desc 'db <OPTION>', 'Execute without options to see HELP.'
    def db(*opts)
      item = opts[0]
              
      option = {
        mysql_switch: 'Switch DB from SQLITE3 to MySQL'
      }
      
      unless item
        say 'ERROR: "myrails db" was called with no arguments'
        say 'Usage: "myrails db <OPTION> <NAME>"'
        say "Available Options:\n"
        option.each{|k,v| say "* #{k}: #{v}"}
        exit
      end
      
      case item
      when 'mysql_switch'
        mysql_switch
      else
        say "Unknown Action!"
      end
    end
    
  end
end