Class: Rage::CLICodeGenerator

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/rage/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



11
12
13
# File 'lib/rage/cli.rb', line 11

def self.source_root
  File.expand_path("templates", __dir__)
end

Instance Method Details

#migration(name = nil) ⇒ Object



16
17
18
19
20
21
# File 'lib/rage/cli.rb', line 16

def migration(name = nil)
  return help("migration") if name.nil?

  setup
  Rake::Task["db:new_migration"].invoke(name)
end

#model(name = nil) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/rage/cli.rb', line 24

def model(name = nil)
  return help("model") if name.nil?

  setup
  migration("create_#{name.pluralize}")
  @model_name = name.classify
  template("model-template/model.rb", "app/models/#{name.singularize.underscore}.rb")
end