class Raca::Users
Represents a collection of users associated with a rackspace account
You probably don’t want to instantiate this directly, see Raca::Account#users
Public Class Methods
new(account, opts = {})
click to toggle source
# File lib/raca/users.rb 8 def initialize(account, opts = {}) 9 @account = account 10 @identity_url = @account.public_endpoint("identity") 11 @logger = opts[:logger] 12 @logger ||= Rails.logger if defined?(Rails) 13 end
Public Instance Methods
get(username)
click to toggle source
# File lib/raca/users.rb 15 def get(username) 16 list.detect { |user| user.username == username } 17 end
inspect()
click to toggle source
# File lib/raca/users.rb 19 def inspect 20 "#<Raca::Users:#{__id__}>" 21 end
Private Instance Methods
identity_client()
click to toggle source
# File lib/raca/users.rb 49 def identity_client 50 @identity_client ||= @account.http_client(identity_host) 51 end
identity_host()
click to toggle source
# File lib/raca/users.rb 37 def identity_host 38 URI.parse(@identity_url).host 39 end
identity_path()
click to toggle source
# File lib/raca/users.rb 41 def identity_path 42 URI.parse(@identity_url).path 43 end
list()
click to toggle source
TODO should this (or something like it) be part of the public API?
# File lib/raca/users.rb 26 def list 27 log "retrieving users list from #{users_path}" 28 response = identity_client.get(users_path) 29 records = JSON.load(response.body)["users"] 30 records.map { |record| 31 record["username"] 32 }.map { |username| 33 Raca::User.new(@account, username) 34 } 35 end
log(msg)
click to toggle source
# File lib/raca/users.rb 53 def log(msg) 54 if @logger.respond_to?(:debug) 55 @logger.debug msg 56 end 57 end
users_path()
click to toggle source
# File lib/raca/users.rb 45 def users_path 46 File.join(identity_path, "users") 47 end