Class: Eucalypt::Generators::Model
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Eucalypt::Generators::Model
- Includes:
- Helpers, Thor::Actions
- Defined in:
- lib/eucalypt/generate/namespaces/generate-model/generators/model.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
12 13 14 |
# File 'lib/eucalypt/generate/namespaces/generate-model/generators/model.rb', line 12 def self.source_root File.join File.dirname(__dir__), 'templates' end |
Instance Method Details
#generate(spec: true, columns: [], table: true, name:) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/eucalypt/generate/namespaces/generate-model/generators/model.rb', line 16 def generate(spec: true, columns: [], table: true, name:) model = Inflect.new(:model, name) config = {class_name: model.class_name} template("model.tt", model.file_path, config) template("model_spec.tt", model.spec_path, config) if spec Eucalypt::CLI.start(['migration', 'create', 'table', Inflect.resources(name), *columns]) if table end |