class TwoFactorDevices::InstallGenerator
Installation generator
-
Copy migration to project
-
Include gem extension to device's owner model
-
Setup TwoFactotdevices initializer
-
Allow to setup email gateway if needed
Public Instance Methods
ask_about_mailer()
click to toggle source
# File lib/generators/two_factor_devices/install_generator.rb, line 31 def ask_about_mailer return unless yes?('Do you want to setup email gateway via rails mailer? [yes/no]') mailer_name = ask('How you prefer to name mailer? [OtpMailer]').presence || 'OtpMailer' generate 'two_factor_devices:email_gateway', mailer_name uncomment_lines( File.join('config', 'initializers', 'two_factor_devices.rb'), /config.email_gateway/ ) end
copy_initializer()
click to toggle source
# File lib/generators/two_factor_devices/install_generator.rb, line 27 def copy_initializer template 'initializer.rb', File.join('config', 'initializers', 'two_factor_devices.rb') end
create_migrations()
click to toggle source
# File lib/generators/two_factor_devices/install_generator.rb, line 14 def create_migrations migration_template File.join('migrations', 'device_table.rb.tt'), File.join('db', 'migrate', 'create_two_factor_devices.rb'), migration_version: migration_version end
include_device_relation()
click to toggle source
# File lib/generators/two_factor_devices/install_generator.rb, line 20 def include_device_relation path = File.join('app', 'models', "#{file_path}.rb") return unless File.exist?(path) inject_into_class(path, class_name, " include TwoFactorDevices::Extensions::TwoFactorDeviceble\n") end
Private Instance Methods
migration_version()
click to toggle source
# File lib/generators/two_factor_devices/install_generator.rb, line 44 def migration_version "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end