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



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

def copy_initializer
  template 'initializer.rb', 'config/initializers/feedy.rb'
end

#copy_migration_fileObject



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

def copy_migration_file
  Dir.chdir(Rails.root) do
    `rake feedy:install:migrations`
  end
end

#determine_current_user_helperObject



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

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



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

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

#mount_engineObject



38
39
40
# File 'lib/generators/feedy/install_generator.rb', line 38

def mount_engine
  route 'mount Feedy::Engine, at: "/feedy"'
end