Class: CouchDB::Security::UsersAndRolesProxy

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

Overview

Proxy to manipulate an array structure of users and roles.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ UsersAndRolesProxy

Returns a new instance of UsersAndRolesProxy.



37
38
39
40
41
# File 'lib/couchdb/security.rb', line 37

def initialize(hash)
  @hash = hash
  @names = @hash["names"] = [ ]
  @roles = @hash["roles"] = [ ]
end

Instance Attribute Details

#namesObject (readonly)

Returns the value of attribute names.



34
35
36
# File 'lib/couchdb/security.rb', line 34

def names
  @names
end

#rolesObject (readonly)

Returns the value of attribute roles.



35
36
37
# File 'lib/couchdb/security.rb', line 35

def roles
  @roles
end

Instance Method Details

#<<(user_or_role) ⇒ Object



48
49
50
51
# File 'lib/couchdb/security.rb', line 48

def <<(user_or_role)
  @names << user_or_role.name if user_or_role.is_a?(CouchDB::User)
  @roles << user_or_role if user_or_role.is_a?(String)
end

#clear!Object



43
44
45
46
# File 'lib/couchdb/security.rb', line 43

def clear!
  @names.clear
  @roles.clear
end