Class: MarkupModel::Generators::ModelGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/markup_model/generators/model_generator.rb

Instance Method Summary collapse

Instance Method Details

#method_nameObject



8
9
10
11
12
13
14
15
# File 'lib/markup_model/generators/model_generator.rb', line 8

def method_name
  klass = class_name.constantize
  id = (klass.markup_model_files.map(&:id).map(&:to_i).max || 0) + 1
  path = "#{MarkupModel.config.content_directory}/#{klass.model_name.plural}/%03d.md" % id

  create_file path,
    "#{YAML.dump(klass.default_yaml_header.stringify_keys)}---\n\nType content here using *Markdown* or <em>HTML</em>."
end