Class: Feedy::Generators::InstallGenerator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_user_helperObject (readonly)

Returns the value of attribute current_user_helper.



11
12
13
# File 'lib/generators/feedy/install_generator.rb', line 11

def current_user_helper
  @current_user_helper
end

#user_classObject (readonly)

Returns the value of attribute user_class.



11
12
13
# File 'lib/generators/feedy/install_generator.rb', line 11

def user_class
  @user_class
end

Instance Method Details

#copy_initializerObject



35
36
37
38
# File 'lib/generators/feedy/install_generator.rb', line 35

def copy_initializer
  puts "Adding Feedy initializer (config/initializers/feedy.rb)..."
  template 'initializer.rb', 'config/initializers/feedy.rb'
end

#copy_migration_fileObject



16
17
18
19
20
21
# File 'lib/generators/feedy/install_generator.rb', line 16

def copy_migration_file
  puts "Copying over Feedy migrations..."
  Dir.chdir(Rails.root) do
    `rake feedy:install:migrations`
  end
end

#determine_current_user_helperObject



29
30
31
32
33
# File 'lib/generators/feedy/install_generator.rb', line 29

def determine_current_user_helper
  @current_user_helper = options["current_user_helper"].presence ||
                         ask("What is the current user helper in your application? [current_user]").presence ||
                         'current_user'
end

#determine_user_classObject



23
24
25
26
27
# File 'lib/generators/feedy/install_generator.rb', line 23

def determine_user_class
  @user_class = options["user_class"].presence ||
                ask("What is your user class called? [User]").presence ||
                "User"
end

#mount_engineObject



40
41
42
43
# File 'lib/generators/feedy/install_generator.rb', line 40

def mount_engine
  puts "Mounting Feedy engine (config/routes.rb)..."
  route 'mount Feedy::Engine, at: "/feedy"'
end