Class: AlphaApi::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- AlphaApi::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/install/install_generator.rb
Instance Method Summary collapse
- #add_denylisted_token_migration ⇒ Object
- #add_denylisted_token_model ⇒ Object
- #add_device_initializer ⇒ Object
- #append_jwt_devise_initializer ⇒ Object
- #copy_initializer ⇒ Object
- #create_user_model ⇒ Object
- #initialize_cancancan ⇒ Object
Instance Method Details
#add_denylisted_token_migration ⇒ Object
30 31 32 |
# File 'lib/generators/install/install_generator.rb', line 30 def add_denylisted_token_migration migration_template "add_denylisted_token.rb", "db/migrate/add_denylisted_token.rb", migration_version: migration_version end |
#add_denylisted_token_model ⇒ Object
26 27 28 |
# File 'lib/generators/install/install_generator.rb', line 26 def add_denylisted_token_model template "denylisted_token.rb.erb", "app/models/denylisted_token.rb" end |
#add_device_initializer ⇒ Object
17 18 19 20 |
# File 'lib/generators/install/install_generator.rb', line 17 def add_device_initializer puts 'Setup device' system 'bundle exec rails generate devise:install' end |
#append_jwt_devise_initializer ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/install/install_generator.rb', line 34 def append_jwt_devise_initializer inject_into_file 'config/initializers/devise.rb', after: "Devise.setup do |config|\n" do <<~HEREDOC config.jwt do |jwt| jwt.secret = Rails.application.secrets.secret_key_base jwt.expiration_time = 24.hours.to_i end HEREDOC end end |
#copy_initializer ⇒ Object
13 14 15 |
# File 'lib/generators/install/install_generator.rb', line 13 def copy_initializer template "alpha_api.rb.erb", "config/initializers/alpha_api.rb" end |
#create_user_model ⇒ Object
22 23 24 |
# File 'lib/generators/install/install_generator.rb', line 22 def create_user_model migration_template "create_devise_users.rb", "db/migrate/create_devise_users.rb", migration_version: migration_version end |
#initialize_cancancan ⇒ Object
47 48 49 50 |
# File 'lib/generators/install/install_generator.rb', line 47 def initialize_cancancan puts 'Setup Cancancan ability class' system 'bundle exec rails generate cancan:ability' end |