Class: AchievableGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/achievable_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



29
30
31
# File 'lib/generators/achievable_generator.rb', line 29

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

Instance Method Details

#add_application_configObject



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

def add_application_config
  inject_into_class "config/application.rb", "Application", <<-CONTENT
  # Set achievable resque
  config.achievable.resque_enable = false

CONTENT
end

#copy_achievable_modelsObject



24
25
26
27
# File 'lib/generators/achievable_generator.rb', line 24

def copy_achievable_models
  template "achievement.rb", "app/models/achievement.rb"
  template "achieving.rb", "app/models/achieving.rb"
end

#manifestObject



20
21
22
# File 'lib/generators/achievable_generator.rb', line 20

def manifest 
  migration_template 'migration.rb', 'db/migrate/achievable_migration'
end

#set_up_achieverObject



6
7
8
9
10
# File 'lib/generators/achievable_generator.rb', line 6

def set_up_achiever  
  inject_into_class "app/models/#{file_name}.rb", class_name, <<-CONTENT
include Achievable::Achiever
CONTENT
end