Class: SocialProfile::Providers::Base
- Inherits:
-
Object
- Object
- SocialProfile::Providers::Base
show all
- Defined in:
- lib/social_profile/providers/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash, options) ⇒ Base
Returns a new instance of Base.
9
10
11
12
|
# File 'lib/social_profile/providers/base.rb', line 9
def initialize(hash, options)
@auth_hash = hash
@options = options
end
|
Instance Attribute Details
#auth_hash ⇒ Object
Returns the value of attribute auth_hash.
7
8
9
|
# File 'lib/social_profile/providers/base.rb', line 7
def auth_hash
@auth_hash
end
|
Instance Method Details
#access_token ⇒ Object
81
82
83
|
# File 'lib/social_profile/providers/base.rb', line 81
def access_token
@access_token ||= credentials['token']
end
|
#avatar_url ⇒ Object
62
63
64
|
# File 'lib/social_profile/providers/base.rb', line 62
def avatar_url
@avatar_url ||= info('image')
end
|
#birthday ⇒ Object
102
103
104
|
# File 'lib/social_profile/providers/base.rb', line 102
def birthday
nil
end
|
#city_name ⇒ Object
74
75
76
77
78
79
|
# File 'lib/social_profile/providers/base.rb', line 74
def city_name
@city_name ||= begin
loc = info('location')
loc.nil? ? nil : loc.split(',').pop().strip
end
end
|
#credentials ⇒ Object
85
86
87
|
# File 'lib/social_profile/providers/base.rb', line 85
def credentials
@credentials ||= (auth_hash['credentials'] || {})
end
|
#email ⇒ Object
94
95
96
|
# File 'lib/social_profile/providers/base.rb', line 94
def email
@email ||= info('email')
end
|
44
45
46
47
48
|
# File 'lib/social_profile/providers/base.rb', line 44
def (key)
if && Utils.exists?(auth_hash['extra'][key])
auth_hash['extra'][key]
end
end
|
50
51
52
|
# File 'lib/social_profile/providers/base.rb', line 50
def
auth_hash['extra'] && auth_hash['extra'].is_a?(Hash)
end
|
#first_name ⇒ Object
26
27
28
|
# File 'lib/social_profile/providers/base.rb', line 26
def first_name
@first_name ||= (info('first_name') || name)
end
|
#gender ⇒ Object
Возвращаемые значения: 1 - женский, 2 - мужской, 0 - без указания пола.
90
91
92
|
# File 'lib/social_profile/providers/base.rb', line 90
def gender
0
end
|
#info(key) ⇒ Object
38
39
40
41
42
|
# File 'lib/social_profile/providers/base.rb', line 38
def info(key)
if info? && Utils.exists?(auth_hash['info'][key])
auth_hash['info'][key]
end
end
|
#info? ⇒ Boolean
54
55
56
|
# File 'lib/social_profile/providers/base.rb', line 54
def info?
auth_hash['info'] && auth_hash['info'].is_a?(Hash)
end
|
#last_name ⇒ Object
30
31
32
|
# File 'lib/social_profile/providers/base.rb', line 30
def last_name
@last_name ||= info('last_name')
end
|
#name ⇒ Object
22
23
24
|
# File 'lib/social_profile/providers/base.rb', line 22
def name
@name ||= info('name')
end
|
#nickname ⇒ Object
34
35
36
|
# File 'lib/social_profile/providers/base.rb', line 34
def nickname
@nickname ||= info('nickname')
end
|
#picture_url ⇒ Object
66
67
68
|
# File 'lib/social_profile/providers/base.rb', line 66
def picture_url
nil
end
|
#profile_url ⇒ Object
70
71
72
|
# File 'lib/social_profile/providers/base.rb', line 70
def profile_url
nil
end
|
#provider ⇒ Object
18
19
20
|
# File 'lib/social_profile/providers/base.rb', line 18
def provider
@provider ||= auth_hash['provider']
end
|
#token_expires_at ⇒ Object
98
99
100
|
# File 'lib/social_profile/providers/base.rb', line 98
def token_expires_at
@token_expires_at ||= parse_datetime(credentials['expires_at'])
end
|
#uid ⇒ Object
14
15
16
|
# File 'lib/social_profile/providers/base.rb', line 14
def uid
@uid ||= auth_hash['uid']
end
|
#works? ⇒ Boolean
58
59
60
|
# File 'lib/social_profile/providers/base.rb', line 58
def works?
false
end
|