class MetaModel::Command::Generate
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
MetaModel::Command::new
# File lib/metamodel/command/generate.rb, line 11 def initialize(argv) @model_name = argv.shift_argument @metafile_path = config.metafile_path super end
Public Instance Methods
run()
click to toggle source
# File lib/metamodel/command/generate.rb, line 17 def run verify_meta_exists! UI.section "Generating model scaffold" do title_options = { :verbose_prefix => '-> '.green } UI.titled_section "Adding `#{@model_name.camelize} model to Metafile", title_options do @metafile_path.open('a') do |source| source.puts model_template(@model_name) end end UI.notice "Adding `#{@model_name.camelize}` model scaffold to Metafile, use the command below to edit it.\n" UI.message "vim Metafile" end end
Private Instance Methods
model_template(model)
click to toggle source
# File lib/metamodel/command/generate.rb, line 33 def model_template(model) <<-TEMPLATE.strip_heredoc define :#{model} do # define #{model} model like this # attr nickname, :string end TEMPLATE end