Class: HasMagickTitle::Generators::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.count!Object



6
7
8
9
# File 'lib/generators/has_magick_title/install_generator.rb', line 6

def self.count!
  @count ||= 0
  (@count += 1) * 3
end

.next_migration_number(path) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/generators/has_magick_title/install_generator.rb', line 11

def self.next_migration_number(path)
  @time ||= Time.new.utc
  if ActiveRecord::Base.timestamped_migrations
    (@time + self.count!).strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#copy_migrationsObject



23
24
25
# File 'lib/generators/has_magick_title/install_generator.rb', line 23

def copy_migrations
  migration_template "add_has_magick_title.rb", "db/migrate/add_has_magick_title.rb"
end