Sha256: 50a353e94374c62ebabf8735d6339dbcd92d025844aa77fd262686ec34ddca68
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module Protolink class User attr_reader :id, :name, :login, :email, :avatar_url def initialize(connection, attributes = {}) @connection = connection @id = attributes['id'] @name = attributes['name'] @login = attributes['login'] @email = attributes['email'] @avatar_url = attributes['avatar_url'] @loaded = false end # get token for autologin def auth_token receive_auth_token end protected def receive_auth_token connection.get("/api/v1/users/auth_token.json?user_id=#{self.id}")['token'] end def load reload! unless @loaded end # does not work yet def reload! attributes = connection.get("/api/v1/users/#{@id}.json")['user'] @id = attributes['id'] @name = attributes['name'] @login = attributes['login'] @email = attributes['email'] @avatar_url = attributes['avatar_url'] @loaded = true end def connection @connection end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
protolink-0.1.1 | lib/protolink/user.rb |
protolink-0.1.0 | lib/protolink/user.rb |