Class: UserAvatar

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/user_avatar.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.discover_from_openid_identifier(openid_identifier) ⇒ Object



9
10
11
12
13
14
15
# File 'app/models/user_avatar.rb', line 9

def self.discover_from_openid_identifier(openid_identifier)
  pavatar = Avatar::Source::PavatarSource.new
  if url = pavatar.avatar_url_for(openid_identifier, :pavatar_field => :openid_identifier)
    openid_identifier.user.avatars.create(:url => url)
  end
rescue
end

.discover_from_user(user) ⇒ Object



17
18
19
20
21
22
# File 'app/models/user_avatar.rb', line 17

def self.discover_from_user(user)
  gravatar = Avatar::Source::GravatarSource.new
  if url = gravatar.avatar_url_for(user)
    user.avatars.create(:url => url)
  end
end

Instance Method Details

#to_sObject



24
25
26
# File 'app/models/user_avatar.rb', line 24

def to_s
  url
end