Class: Sorcery::Providers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sorcery/providers/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



13
14
15
# File 'lib/sorcery/providers/base.rb', line 13

def initialize
  @user_info_mapping = {}
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



4
5
6
# File 'lib/sorcery/providers/base.rb', line 4

def access_token
  @access_token
end

#callback_urlObject

Returns the value of attribute callback_url.



6
7
8
# File 'lib/sorcery/providers/base.rb', line 6

def callback_url
  @callback_url
end

#keyObject

Returns the value of attribute key.



6
7
8
# File 'lib/sorcery/providers/base.rb', line 6

def key
  @key
end

#original_callback_urlObject

Returns the value of attribute original_callback_url.



6
7
8
# File 'lib/sorcery/providers/base.rb', line 6

def original_callback_url
  @original_callback_url
end

#secretObject

Returns the value of attribute secret.



6
7
8
# File 'lib/sorcery/providers/base.rb', line 6

def secret
  @secret
end

#siteObject

Returns the value of attribute site.



6
7
8
# File 'lib/sorcery/providers/base.rb', line 6

def site
  @site
end

#stateObject

Returns the value of attribute state.



6
7
8
# File 'lib/sorcery/providers/base.rb', line 6

def state
  @state
end

#user_info_mappingObject

Returns the value of attribute user_info_mapping.



6
7
8
# File 'lib/sorcery/providers/base.rb', line 6

def 
  @user_info_mapping
end

Class Method Details

.descendantsObject

Ensure that all descendant classes are loaded before run this



33
34
35
# File 'lib/sorcery/providers/base.rb', line 33

def self.descendants
  ObjectSpace.each_object(Class).select { |klass| klass < self }
end

.nameObject



28
29
30
# File 'lib/sorcery/providers/base.rb', line 28

def self.name
  super.gsub(/Sorcery::Providers::/, '').downcase
end

Instance Method Details

#auth_hash(access_token, hash = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/sorcery/providers/base.rb', line 17

def auth_hash(access_token, hash = {})
  return hash if access_token.nil?

  token_hash = hash.dup
  token_hash[:token] = access_token.token if access_token.respond_to?(:token)
  token_hash[:refresh_token] = access_token.refresh_token if access_token.respond_to?(:refresh_token)
  token_hash[:expires_at] = access_token.expires_at if access_token.respond_to?(:expires_at)
  token_hash[:expires_in] = access_token.expires_at if access_token.respond_to?(:expires_in)
  token_hash
end

#has_callback?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/sorcery/providers/base.rb', line 9

def has_callback?
  true
end