class Raca::User
Represents a single user within the current account.
You probably don’t want to instantiate this directly, see Raca::Account#users
Attributes
username[R]
Public Class Methods
new(account, username, opts = {})
click to toggle source
# File lib/raca/user.rb 10 def initialize(account, username, opts = {}) 11 @account, @username = account, username 12 @identity_url = @account.public_endpoint("identity") 13 @logger = opts[:logger] 14 @logger ||= Rails.logger if defined?(Rails) 15 end
Public Instance Methods
details()
click to toggle source
# File lib/raca/user.rb 17 def details 18 response = identity_client.get(user_path) 19 JSON.load(response.body)["user"] 20 end
inspect()
click to toggle source
# File lib/raca/user.rb 22 def inspect 23 "#<Raca::User:#{__id__} @username=#{@username}>" 24 end
Private Instance Methods
identity_client()
click to toggle source
# File lib/raca/user.rb 40 def identity_client 41 @identity_client ||= @account.http_client(identity_host) 42 end
identity_host()
click to toggle source
# File lib/raca/user.rb 28 def identity_host 29 URI.parse(@identity_url).host 30 end
identity_path()
click to toggle source
# File lib/raca/user.rb 32 def identity_path 33 URI.parse(@identity_url).path 34 end
log(msg)
click to toggle source
# File lib/raca/user.rb 44 def log(msg) 45 if @logger.respond_to?(:debug) 46 @logger.debug msg 47 end 48 end
user_path()
click to toggle source
# File lib/raca/user.rb 36 def user_path 37 @user_path ||= File.join(identity_path, "users") + "?name=" + Raca::Util.url_encode(@username) 38 end