Class: Decidim::OmniauthProvider

Inherits:
Object
  • Object
show all
Defined in:
app/models/decidim/omniauth_provider.rb

Class Method Summary collapse

Class Method Details

.availableObject



5
6
7
# File 'app/models/decidim/omniauth_provider.rb', line 5

def self.available
  Rails.application.secrets[:omniauth] || {}
end

.enabledObject



9
10
11
12
13
# File 'app/models/decidim/omniauth_provider.rb', line 9

def self.enabled
  available.select do |_provider, settings|
    settings[:enabled] == true
  end
end

.extract_provider_key(enabled_setting_key) ⇒ Object



15
16
17
18
# File 'app/models/decidim/omniauth_provider.rb', line 15

def self.extract_provider_key(enabled_setting_key)
  enabled_setting_key.gsub("omniauth_settings_", "")
                     .gsub("_enabled", "").to_sym
end

.extract_setting_key(setting_key, provider) ⇒ Object



20
21
22
# File 'app/models/decidim/omniauth_provider.rb', line 20

def self.extract_setting_key(setting_key, provider)
  setting_key.gsub("omniauth_settings_#{provider}_", "").to_sym
end

.value_defined?(value) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/decidim/omniauth_provider.rb', line 24

def self.value_defined?(value)
  value.is_a?(String) && value.present?
end