Class: CouchDB::Security
- Inherits:
-
Object
- Object
- CouchDB::Security
- Defined in:
- lib/couchdb/security.rb
Overview
Abstracts a CouchDB database security document.
Defined Under Namespace
Classes: UsersAndRolesProxy
Instance Attribute Summary collapse
-
#administrators ⇒ Object
readonly
Returns the value of attribute administrators.
-
#readers ⇒ Object
readonly
Returns the value of attribute readers.
Instance Method Summary collapse
-
#initialize(database) ⇒ Security
constructor
A new instance of Security.
- #load ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(database) ⇒ Security
Returns a new instance of Security.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/couchdb/security.rb', line 8 def initialize(database) @database = database @document = CouchDB::Document.new @database @document.id = "_security" @document.fetch_rev @document["admins"] = { } @document["readers"] = { } @administrators = UsersAndRolesProxy.new @document["admins"] @readers = UsersAndRolesProxy.new @document["readers"] end |
Instance Attribute Details
#administrators ⇒ Object (readonly)
Returns the value of attribute administrators.
5 6 7 |
# File 'lib/couchdb/security.rb', line 5 def administrators @administrators end |
#readers ⇒ Object (readonly)
Returns the value of attribute readers.
6 7 8 |
# File 'lib/couchdb/security.rb', line 6 def readers @readers end |
Instance Method Details
#load ⇒ Object
21 22 23 |
# File 'lib/couchdb/security.rb', line 21 def load @document.load end |
#save ⇒ Object
25 26 27 28 29 |
# File 'lib/couchdb/security.rb', line 25 def save @document.save rescue Transport::UnexpectedStatusCodeError => error raise error unless error.status_code == 200 end |