Class: Grendel::UserManager
- Inherits:
-
Object
- Object
- Grendel::UserManager
- Defined in:
- lib/grendel/user_manager.rb
Instance Method Summary collapse
-
#create(id, password) ⇒ Object
create a new user.
-
#find(id, password = nil) ⇒ Object
retrieve a user, optionally setting the password.
-
#initialize(client) ⇒ UserManager
constructor
A new instance of UserManager.
-
#list ⇒ Object
return all Grendel users as Grendel::User objects.
Constructor Details
#initialize(client) ⇒ UserManager
Returns a new instance of UserManager.
4 5 6 |
# File 'lib/grendel/user_manager.rb', line 4 def initialize(client) @client = client end |
Instance Method Details
#create(id, password) ⇒ Object
create a new user
23 24 25 26 27 28 |
# File 'lib/grendel/user_manager.rb', line 23 def create(id, password) params = {:id => id, :password => password} response = @client.post("/users", params) # TODO: strip protocol and host from uri User.new(@client, params.merge(:uri => response.headers['location'].first)) end |
#find(id, password = nil) ⇒ Object
retrieve a user, optionally setting the password
15 16 17 18 19 20 |
# File 'lib/grendel/user_manager.rb', line 15 def find(id, password = nil) response = @client.get("/users/#{id}") # need to escape this user = User.new(@client, response) user.password = password return user end |