summaryrefslogtreecommitdiff
path: root/lib/leap/users.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leap/users.rb')
-rw-r--r--lib/leap/users.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/leap/users.rb b/lib/leap/users.rb
new file mode 100644
index 0000000..14c9c4e
--- /dev/null
+++ b/lib/leap/users.rb
@@ -0,0 +1,36 @@
+require 'couchrest'
+
+module LEAP
+ class Users < CouchRest::Database
+
+ def initialize(server)
+ super(server, 'users')
+ end
+
+ def find_by_login(login)
+ record = self.view('User/by_login',
+ :reduce => false,
+ :startkey => login,
+ :endkey => login
+ )['rows'].first
+ if record
+ return self.get(record['id'])
+ end
+ end
+
+ def all_logins
+ self.view('User/by_login',
+ :reduce => false
+ )['rows'].map {|row|
+ row['key']
+ }
+ end
+
+ def all_active_ids
+ end
+
+ def all_ids
+ end
+
+ end
+end