Class: GoogleAuthentication::Generators::GoogleAuthenticationGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- GoogleAuthentication::Generators::GoogleAuthenticationGenerator
- Includes:
- Devise::Generators::OrmHelpers
- Defined in:
- lib/generators/google_authentication/google_authentication_generator.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#copy_devise_migration ⇒ Object
Build the migration files for the given model.
-
#generate_model ⇒ Object
Generate the model without a migration file using the active_record generator.
-
#inject_google_authentication_content ⇒ Object
Insert gem activation code into the selected class.
-
#show_readme ⇒ Object
Show a readme file with further instructions after installation.
Instance Method Details
#copy_devise_migration ⇒ Object
Build the migration files for the given model
25 26 27 |
# File 'lib/generators/google_authentication/google_authentication_generator.rb', line 25 def copy_devise_migration migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb" end |
#generate_model ⇒ Object
Generate the model without a migration file using the active_record generator
20 21 22 |
# File 'lib/generators/google_authentication/google_authentication_generator.rb', line 20 def generate_model invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke end |
#inject_google_authentication_content ⇒ Object
Insert gem activation code into the selected class
30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/google_authentication/google_authentication_generator.rb', line 30 def inject_google_authentication_content inject_into_class(model_path, class_name) do return nil unless model_exists? " # You can add other devise modules here as arguments, as in devise calls. :omniauthable module is always added\n" << " # and forbidden devise modules are automatically removed (see GoogleAuthentication::ActsAsGoogleUser::FORBIDDEN_MODULES)\n" << " # if you change this line, remember to edit the generated migration\n" << " acts_as_google_user\n" end end |
#show_readme ⇒ Object
Show a readme file with further instructions after installation
41 42 43 |
# File 'lib/generators/google_authentication/google_authentication_generator.rb', line 41 def show_readme readme "MODEL.warning" if behavior == :invoke && class_name != 'User' end |