Class: Sunrise::Questions::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_timeObject



14
15
16
17
# File 'lib/generators/sunrise/questions/install_generator.rb', line 14

def self.current_time
  @current_time ||= Time.now
  @current_time += 1.minute
end

.next_migration_number(dirname) ⇒ Object



19
20
21
# File 'lib/generators/sunrise/questions/install_generator.rb', line 19

def self.next_migration_number(dirname)
  current_time.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create_migrationObject



27
28
29
30
31
# File 'lib/generators/sunrise/questions/install_generator.rb', line 27

def create_migration
  if options.migrations
    migration_template "create_questions.rb", File.join('db/migrate', "sunrise_create_questions.rb")
  end
end

#create_modelObject



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

def create_model
  copy_file('question.rb', 'app/models/question.rb')
end