Class: Authinator::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/authinator/provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Provider

Returns a new instance of Provider.



11
12
13
14
15
16
17
18
19
# File 'lib/authinator/provider.rb', line 11

def initialize(name, options = {})
  @name = name
  @client_id = options.delete :client_id
  @client_secret = options.delete :client_secret
  @site = options.delete :site
  @token_url = options.delete :token_url
  @api_key = options.delete :api_key
  @user_info_url = options.delete :user_info_url
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/authinator/provider.rb', line 4

def api_key
  @api_key
end

#client_idObject

Returns the value of attribute client_id.



4
5
6
# File 'lib/authinator/provider.rb', line 4

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



4
5
6
# File 'lib/authinator/provider.rb', line 4

def client_secret
  @client_secret
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/authinator/provider.rb', line 3

def name
  @name
end

#siteObject

Returns the value of attribute site.



4
5
6
# File 'lib/authinator/provider.rb', line 4

def site
  @site
end

#token_urlObject

Returns the value of attribute token_url.



4
5
6
# File 'lib/authinator/provider.rb', line 4

def token_url
  @token_url
end

#user_info_urlObject

Returns the value of attribute user_info_url.



4
5
6
# File 'lib/authinator/provider.rb', line 4

def 
  @user_info_url
end

Instance Method Details

#add_secrets(options = {}) ⇒ Object



21
22
23
24
25
# File 'lib/authinator/provider.rb', line 21

def add_secrets(options = {})
  @client_id = options.delete :client_id if options[:client_id]
  @client_secret = options.delete :client_secret if options[:client_secret]
  @api_key = options.delete :api_key if options[:api_key]
end

#empty?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/authinator/provider.rb', line 48

def empty?
  to_hash.empty?
end

#secretsObject



27
28
29
30
31
32
33
34
# File 'lib/authinator/provider.rb', line 27

def secrets
  sec = {}
  sec[:client_id] = @client_id if @client_id
  sec[:client_secret] = @client_secret if @client_secret
  sec[:api_key] = @api_key if @api_key

  sec
end

#to_hashObject Also known as: inspect



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/authinator/provider.rb', line 36

def to_hash
  {
    name: @name,
    client_id: @client_id,
    client_secret: @client_secret,
    site: @site,
    token_url: @token_url,
    api_key: @api_key,
    user_info_url: @user_info_url,
  }
end