class SeriousBusiness::Generators::InstallGenerator

Public Class Methods

next_migration_number(dirname) click to toggle source

Define the next_migration_number method (necessary for the migration_template method to work)

# File lib/generators/serious_business/install_generator.rb, line 32
def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    sleep 1 # make sure each time we get a different timestamp
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Public Instance Methods

copy_initializer_file() click to toggle source

Copy the initializer file to config/initializers folder.

# File lib/generators/serious_business/install_generator.rb, line 15
def copy_initializer_file
  template "initializer.rb", "config/initializers/serious_business.rb"
end
copy_migration_files() click to toggle source

Copy the migrations files to db/migrate folder

# File lib/generators/serious_business/install_generator.rb, line 24
def copy_migration_files
  # Copy core migration file in all cases except when you pass --only-submodules.
  return unless defined?(SeriousBusiness::Generators::InstallGenerator::ActiveRecord)
  migration_template "migration/actions.rb", "db/migrate/create_serious_business.rb", migration_class_name: migration_class_name

end
use_uuid() click to toggle source
# File lib/generators/serious_business/install_generator.rb, line 19
def use_uuid
  options.key? :use_uuid
end

Private Instance Methods

migration_class_name() click to toggle source
# File lib/generators/serious_business/install_generator.rb, line 43
def migration_class_name
  if Rails::VERSION::MAJOR >= 5
    "ActiveRecord::Migration[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
  else
    "ActiveRecord::Migration"
  end
end