Class: Sorcery::Providers::Base

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

Direct Known Subclasses

Facebook, Github, Google, Heroku, Jira, Linkedin, Liveid, Salesforce, Twitter, Vk, Xing

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



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

def initialize
  @user_info_mapping = {}
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#callback_urlObject

Returns the value of attribute callback_url.



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

def callback_url
  @callback_url
end

#keyObject

Returns the value of attribute key.



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

def key
  @key
end

#original_callback_urlObject

Returns the value of attribute original_callback_url.



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

def original_callback_url
  @original_callback_url
end

#secretObject

Returns the value of attribute secret.



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

def secret
  @secret
end

#siteObject

Returns the value of attribute site.



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

def site
  @site
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#user_info_mappingObject

Returns the value of attribute user_info_mapping.



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

def 
  @user_info_mapping
end

Class Method Details

.descendantsObject

Ensure that all descendant classes are loaded before run this



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

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

.nameObject



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

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

Instance Method Details

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



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

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)


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

def has_callback?; true; end