Class: OsCtld::DB::Users

Inherits:
PooledList show all
Defined in:
lib/osctld/db/users.rb

Instance Attribute Summary

Attributes inherited from List

#objects

Instance Method Summary collapse

Methods inherited from PooledList

#contains?, #find

Methods inherited from List

#contains?, #count, #find, #get, instance, #sync

Constructor Details

#initialize(*_) ⇒ Users

Returns a new instance of Users



14
15
16
17
# File 'lib/osctld/db/users.rb', line 14

def initialize(*_)
  super
  @ugid_index = OsCtl::Lib::Index.new { |u| u.ugid }
end

Instance Method Details

#add(user) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/osctld/db/users.rb', line 19

def add(user)
  sync do
    OsCtld::UGidRegistry << user.ugid
    super
    @ugid_index << user
  end
end

#by_ugid(ugid) ⇒ Object



39
40
41
# File 'lib/osctld/db/users.rb', line 39

def by_ugid(ugid)
  sync { @ugid_index[ugid] }
end

#remove(user) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/osctld/db/users.rb', line 27

def remove(user)
  sync do
    unless OsCtld::SystemUsers.include?(user.sysusername)
      OsCtld::UGidRegistry.remove(user.ugid)
    end

    super
    @ugid_index.delete(user)
    user
  end
end