Class: GoogleAuthentication::Generators::GoogleAuthenticationGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Includes:
Devise::Generators::OrmHelpers
Defined in:
lib/generators/google_authentication/google_authentication_generator.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#copy_devise_migrationObject

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_modelObject

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_contentObject

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_readmeObject

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