Class: CouchDB::UserDatabase

Inherits:
Object
  • Object
show all
Defined in:
lib/couchdb/user_database.rb

Overview

Wraps all methods for the user database.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, name = "_users") ⇒ UserDatabase

Returns a new instance of UserDatabase.



8
9
10
11
# File 'lib/couchdb/user_database.rb', line 8

def initialize(server, name = "_users")
  @server = server
  @database = CouchDB::Database.new @server, name
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



6
7
8
# File 'lib/couchdb/user_database.rb', line 6

def database
  @database
end

#serverObject (readonly)

Returns the value of attribute server.



5
6
7
# File 'lib/couchdb/user_database.rb', line 5

def server
  @server
end

Instance Method Details

#usersObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/couchdb/user_database.rb', line 13

def users
  @database.documents.map do |row|
    if row.id =~ /^org\.couchdb\.user:.+$/
      user = CouchDB::User.new self, row.id.sub(/^org\.couchdb\.user:/, "")
      user.load
      user
    else
      nil
    end
  end.compact
end