Class: LittleBrotherSetupGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



9
10
11
# File 'lib/generators/little_brother_setup/little_brother_setup_generator.rb', line 9

def self.next_migration_number(path)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#migrationObject



13
14
15
16
17
18
19
# File 'lib/generators/little_brother_setup/little_brother_setup_generator.rb', line 13

def migration
  unless watchers_table_exists? # SOURCE -> DESTINATION
    puts "* watchers table creation migration was created!"
    puts "* run rake db:migrate"
    migration_template "db/migrate/create_watchers.rb", "db/migrate/create_watchers.rb"
  end
end

#watchers_table_exists?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/generators/little_brother_setup/little_brother_setup_generator.rb', line 21

def watchers_table_exists?
  ActiveRecord::Base.connection.table_exists?(:watchers)
end