class Padrino::Generators::Model

Responsible for generating new models for the specified ORM component.

Public Class Methods

banner() click to toggle source
source_root() click to toggle source
# File lib/padrino-gen/generators/model.rb, line 9
def self.source_root; File.expand_path(File.dirname(__FILE__)); end

Public Instance Methods

create_model() click to toggle source

Execute the model generation.

# File lib/padrino-gen/generators/model.rb, line 31
def create_model
  app = options[:app]
  return unless valid_model_for?(app)

  include_component_module_for(:test)
  migration_name = "create_#{name.pluralize.underscore}"
  apply_default_fields fields
  create_model_file(name, :fields => fields, :app => app)
  generate_model_test(name) if test?
  create_model_migration(migration_name, name, fields) unless options[:skip_migration]
end