Sha256: 27302b7d7e8b327d5520dca25130291882f300351968a6f31b9108677c5b433d
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
module Shieldify class InstallGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path("templates", __dir__) def copy_initializer template 'initializer.rb', File.join("config", "initializers", "shieldify.rb") end def generate_migration migration_template 'migration.rb', File.join("db", "migrate", "shieldify_create_users.rb"), migration_version: migration_version end def generate_model template 'model.rb', File.join("app", "models", "user.rb") end def inject_method inject_into_class File.join("app", "models", "user.rb"), :User, model_contents end def copy_mailer_layouts directory File.join("mailer_layouts"), File.join("app", "views", "layouts", "shieldify") end def copy_mailer_views directory File.join("mailer_views"), File.join("app", "views", "shieldify", "mailer") end def copy_locale_file template "locales/en.shieldify.yml", File.join("config", "locales", "en.shieldify.yml") end private def model_contents <<-CONTENT shieldify email_authenticatable: %i[registerable confirmable] CONTENT end def migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 ActiveRecord::Migration.next_migration_number(next_migration_number) end end end
Version data entries
3 entries across 3 versions & 1 rubygems