Class: Rodauth::Rails::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration, MigrationHelpers
Defined in:
lib/generators/rodauth/install_generator.rb

Constant Summary collapse

MAILER_VIEWS =
%w[
  email_auth
  password_changed
  reset_password
  unlock_account
  verify_account
  verify_login_change
]

Instance Attribute Summary

Attributes included from MigrationHelpers

#migration_class_name

Instance Method Summary collapse

Methods included from MigrationHelpers

#migration_template

Instance Method Details

#create_account_modelObject



53
54
55
56
57
# File 'lib/generators/rodauth/install_generator.rb', line 53

def 
  return unless defined?(ActiveRecord::Base)

  template "app/models/account.rb"
end

#create_mailerObject



59
60
61
62
63
64
65
# File 'lib/generators/rodauth/install_generator.rb', line 59

def create_mailer
  template "app/mailers/rodauth_mailer.rb"

  MAILER_VIEWS.each do |view|
    template "app/views/rodauth_mailer/#{view}.text.erb"
  end
end

#create_rodauth_appObject



45
46
47
# File 'lib/generators/rodauth/install_generator.rb', line 45

def create_rodauth_app
  template "app/lib/rodauth_app.rb"
end

#create_rodauth_controllerObject



49
50
51
# File 'lib/generators/rodauth/install_generator.rb', line 49

def create_rodauth_controller
  template "app/controllers/rodauth_controller.rb"
end

#create_rodauth_initializerObject



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

def create_rodauth_initializer
  template "config/initializers/rodauth.rb"
end

#create_rodauth_migrationObject



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

def create_rodauth_migration
  return unless defined?(ActiveRecord::Base)

  migration_template "db/migrate/create_rodauth.rb"
end

#create_sequel_initializerObject



38
39
40
41
42
43
# File 'lib/generators/rodauth/install_generator.rb', line 38

def create_sequel_initializer
  return unless defined?(ActiveRecord::Base)
  return if defined?(Sequel) && !Sequel::DATABASES.empty?

  template "config/initializers/sequel.rb"
end