class SocialProfile::Providers::Base
Attributes
auth_hash[R]
Public Class Methods
new(hash, options)
click to toggle source
# File lib/social_profile/providers/base.rb, line 9 def initialize(hash, options) @auth_hash = hash @options = options end
Public Instance Methods
access_token()
click to toggle source
# File lib/social_profile/providers/base.rb, line 81 def access_token @access_token ||= credentials['token'] end
avatar_url()
click to toggle source
# File lib/social_profile/providers/base.rb, line 62 def avatar_url @avatar_url ||= info('image') end
birthday()
click to toggle source
# File lib/social_profile/providers/base.rb, line 102 def birthday nil end
city_name()
click to toggle source
# 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()
click to toggle source
# File lib/social_profile/providers/base.rb, line 85 def credentials @credentials ||= (auth_hash['credentials'] || {}) end
email()
click to toggle source
# File lib/social_profile/providers/base.rb, line 94 def email @email ||= info('email') end
extra(key)
click to toggle source
# File lib/social_profile/providers/base.rb, line 44 def extra(key) if extra? && Utils.exists?(auth_hash['extra'][key]) auth_hash['extra'][key] end end
extra?()
click to toggle source
# File lib/social_profile/providers/base.rb, line 50 def extra? auth_hash['extra'] && auth_hash['extra'].is_a?(Hash) end
first_name()
click to toggle source
# File lib/social_profile/providers/base.rb, line 26 def first_name @first_name ||= (info('first_name') || name) end
gender()
click to toggle source
Возвращаемые значения: 1 - женский, 2 - мужской, 0 - без указания пола.
# File lib/social_profile/providers/base.rb, line 90 def gender 0 end
info(key)
click to toggle source
# 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?()
click to toggle source
# File lib/social_profile/providers/base.rb, line 54 def info? auth_hash['info'] && auth_hash['info'].is_a?(Hash) end
last_name()
click to toggle source
# File lib/social_profile/providers/base.rb, line 30 def last_name @last_name ||= info('last_name') end
name()
click to toggle source
# File lib/social_profile/providers/base.rb, line 22 def name @name ||= info('name') end
nickname()
click to toggle source
# File lib/social_profile/providers/base.rb, line 34 def nickname @nickname ||= info('nickname') end
picture_url()
click to toggle source
# File lib/social_profile/providers/base.rb, line 66 def picture_url nil end
profile_url()
click to toggle source
# File lib/social_profile/providers/base.rb, line 70 def profile_url nil end
provider()
click to toggle source
# File lib/social_profile/providers/base.rb, line 18 def provider @provider ||= auth_hash['provider'] end
token_expires_at()
click to toggle source
# File lib/social_profile/providers/base.rb, line 98 def token_expires_at @token_expires_at ||= parse_datetime(credentials['expires_at']) end
uid()
click to toggle source
# File lib/social_profile/providers/base.rb, line 14 def uid @uid ||= auth_hash['uid'] end
works?()
click to toggle source
# File lib/social_profile/providers/base.rb, line 58 def works? false end
Protected Instance Methods
parse_datetime(value)
click to toggle source
# File lib/social_profile/providers/base.rb, line 108 def parse_datetime(value) return nil if Utils.blank?(value) || value.to_i.zero? Time.at(value.to_i).to_datetime end