Module: OAuth2Me

Defined in:
lib/oauth2-me.rb,
lib/oauth2-me/railtie.rb,
lib/oauth2-me/version.rb,
lib/oauth2-me/omniauth_strategy_updater.rb

Defined Under Namespace

Classes: BannedEnvironmentError, OmniauthStrategyUpdater, Railtie

Constant Summary collapse

VERSION =
'0.1.1'

Class Method Summary collapse

Class Method Details

.banned_environmentsObject



11
12
13
# File 'lib/oauth2-me.rb', line 11

def banned_environments
  @@banned_environments = ['production']
end

.check_setup!Object



28
29
30
31
# File 'lib/oauth2-me.rb', line 28

def check_setup!
  environment = ENV['RAILS_ENV'] || ENV['RACK_ENV']
  raise BannedEnvironmentError.new if environment && banned_environments.include?(environment)
end

.omniauth_strategy_updaterObject



15
16
17
# File 'lib/oauth2-me.rb', line 15

def omniauth_strategy_updater
  @@omniauth_strategy_updater ||= OAuth2Me::OmniauthStrategyUpdater.new
end

.setup_devise!Object



19
20
21
22
23
24
25
26
# File 'lib/oauth2-me.rb', line 19

def setup_devise!
  check_setup!
  Devise::OmniAuth::Config.send :define_method, :strategy_class_with_redirect do
    strategy_class = strategy_class_without_redirect
    OAuth2Me.omniauth_strategy_updater.setup_omniauth_strategy(strategy_class)
  end
  Devise::OmniAuth::Config.alias_method_chain :strategy_class, :redirect
end