Module: GoodGuide::Accounts::Profile
- Included in:
- Base
- Defined in:
- lib/goodguide/accounts/profile.rb
Instance Method Summary collapse
- #facebook? ⇒ Boolean
- #full_name ⇒ Object
- #given_name ⇒ Object
- #identifier ⇒ Object
- #profile_picture(size = nil) ⇒ Object
- #with_profile(default = nil, &block) ⇒ Object
Instance Method Details
#facebook? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/goodguide/accounts/profile.rb', line 40 def facebook? with_profile(false) do |profile| profile["identifier"] && profile["identifier"].include?("facebook.com") end end |
#full_name ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/goodguide/accounts/profile.rb', line 24 def full_name with_profile do |profile| name = profile["name"]["formatted"] !name.blank? ? name.strip : "GoodGuide User" end end |
#given_name ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/goodguide/accounts/profile.rb', line 14 def given_name with_profile do |profile| name = profile["name"]["givenName"] || profile["displayName"] || profile["name"]["formatted"] !name.blank? ? name.strip : "GoodGuide User" end end |
#identifier ⇒ Object
8 9 10 11 12 |
# File 'lib/goodguide/accounts/profile.rb', line 8 def identifier with_profile do |profile| profile['identifier'] end end |
#profile_picture(size = nil) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/goodguide/accounts/profile.rb', line 32 def profile_picture(size = nil) with_profile do |profile| photo = profile["photo"] photo.gsub!("=large", "=#{size}") if facebook? and size.present? photo end end |
#with_profile(default = nil, &block) ⇒ Object
4 5 6 |
# File 'lib/goodguide/accounts/profile.rb', line 4 def with_profile(default = nil, &block) profile? ? yield(profile) : default end |