Class: Omniauth::MultipleProviders::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/omniauth/multiple_providers/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_multiple_providers_routesObject



25
26
27
28
29
# File 'lib/generators/omniauth/multiple_providers/install/install_generator.rb', line 25

def add_multiple_providers_routes
  route "get '/auth/:provider/callback' => 'omniauth/multiple_providers#create'"
  route "get '/auth/failure' => 'omniauth/multiple_providers#failure'"
  route "resources :omniauth, only: [:new, :create, :failure, :destroy], controller: 'omniauth/multiple_providers'"
end

#add_provider_userObject



9
10
11
# File 'lib/generators/omniauth/multiple_providers/install/install_generator.rb', line 9

def add_provider_user
  copy_file 'provider_user.rb', 'app/models/provider_user.rb'
end

#create_provider_userObject



13
14
15
16
# File 'lib/generators/omniauth/multiple_providers/install/install_generator.rb', line 13

def create_provider_user
  # FIXME add datetime require
  copy_file 'create_provider_users.rb', "db/migrate/#{DateTime.now.strftime('%Y%m%d%H%M%S')}_create_provider_users.rb"
end

#insert_to_userObject



18
19
20
21
22
23
# File 'lib/generators/omniauth/multiple_providers/install/install_generator.rb', line 18

def insert_to_user
  #insert_into_file 'app/models/user.rb', '  include Omniauth::MultipleProviders::Omniauthable', after: 'class User < ActiveRecord::Base'
  inject_into_class 'app/models/user.rb', User do
    "  include Omniauth::MultipleProviders::Omniauthable\n"
  end
end