Class: Draftsman::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/draftsman/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



33
34
35
# File 'lib/generators/draftsman/install_generator.rb', line 33

def self.next_migration_number(dirname)
  ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#copy_configObject



37
38
39
# File 'lib/generators/draftsman/install_generator.rb', line 37

def copy_config
  template 'config/initializers/draftsman.rb' unless options.skip_initializer?
end

#create_migration_fileObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/draftsman/install_generator.rb', line 15

def create_migration_file
  if options.with_pg_json?
    migration_template 'create_drafts_json.rb', 'db/migrate/create_drafts.rb'

    if options.with_changes?
      migration_template 'add_object_changes_column_to_drafts_json.rb',
                         'db/migrate/add_object_changes_column_to_drafts.rb'
    end
  else
    migration_template 'create_drafts.rb', 'db/migrate/create_drafts.rb'

    if options.with_changes?
      migration_template 'add_object_changes_column_to_drafts.rb',
                         'db/migrate/add_object_changes_column_to_drafts.rb'
    end
  end
end