Class: HasFriendshipUpdateGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



11
12
13
14
15
16
# File 'lib/generators/has_friendship_update/has_friendship_update_generator.rb', line 11

def self.next_migration_number(path)
  next_num = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
  current_num = current_migration_number(path)
  next_num += (current_num - next_num + 1) if current_num >= next_num
  next_num.to_s
end

.source_rootObject



7
8
9
# File 'lib/generators/has_friendship_update/has_friendship_update_generator.rb', line 7

def self.source_root
  File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#create_migration_fileObject



18
19
20
21
# File 'lib/generators/has_friendship_update/has_friendship_update_generator.rb', line 18

def create_migration_file
  migration_template 'update_friendships.rb',
                     'db/migrate/update_friendships.rb'
end