Class: AuthHash

Inherits:
Object
  • Object
show all
Defined in:
app/services/auth_hash.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_hash) ⇒ AuthHash

Returns a new instance of AuthHash


6
7
8
# File 'app/services/auth_hash.rb', line 6

def initialize(user_hash)
  @user_hash = user_hash
end

Class Method Details

.extract_user_info(hash) ⇒ Object


2
3
4
# File 'app/services/auth_hash.rb', line 2

def self.(hash)
  AuthHash.new(hash).
end

Instance Method Details

#user_infoObject


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/auth_hash.rb', line 10

def 
  h = {
    token:       token,
    uid:         uid,
    nickname:    nickname,
    email:       email,
    gravatar_id: gravatar_id
  }
  h.merge!(public_repo_token: public_repo_token) if public_repo_token.present?
  h.merge!(private_repo_token: private_repo_token) if private_repo_token.present?
  h.merge!(token_upgrade: false) if public_repo_token.present? || private_repo_token.present?
  h
end