Skip to content

Instantly share code, notes, and snippets.

@vinibaggio
Created May 8, 2012 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinibaggio/2638924 to your computer and use it in GitHub Desktop.
Save vinibaggio/2638924 to your computer and use it in GitHub Desktop.
class FacebookUser
def initialize(data)
@uid = data.uid
@first_name = data.info.first_name
@last_name = data.info.last_name
@email = data.info.email
@image = data.info.image
@urls = data.info.urls['Facebook']
@token = data.credentials.token
end
def build_user(user = User.new)
user.uid = @uid
user.first_name = @first_name
user.last_name = @last_name
user.email = @email
user.image = @image
user.profile_url = @urls
user.oauth_token = @token
user
end
def create_user
build_user.tap(&:save)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment