added script destroy-user-db
[couchdb_scripts.git] / lib / leap / users.rb
1 require 'couchrest'
2
3 module LEAP
4   class Users < CouchRest::Database
5
6     def initialize(server)
7       super(server, 'users')
8     end
9
10     def find_by_login(login)
11       record = self.view('User/by_login',
12         :reduce => false,
13         :startkey => login,
14         :endkey => login
15       )['rows'].first
16       if record
17         return self.get(record['id'])
18       end
19     end
20
21     def all_logins
22       self.view('User/by_login',
23         :reduce => false
24       )['rows'].map {|row|
25         row['key']
26       }
27     end
28
29     def all_active_ids
30     end
31
32     def all_ids
33     end
34
35   end
36 end