Class: UnixUserManager::File::Passwd

Inherits:
Base
  • Object
show all
Defined in:
lib/unix_user_manager/file/passwd.rb

Instance Attribute Summary

Attributes inherited from Base

#data, #new_records, #source

Instance Method Summary collapse

Methods inherited from Base

#all, #build, #can_add?, #exist?, #find, #find_by_id, #id_exist?, #ids, #initialize

Constructor Details

This class inherits a constructor from UnixUserManager::File::Base

Instance Method Details

#add(name:, uid:, gid:) ⇒ Object



2
3
4
5
6
7
# File 'lib/unix_user_manager/file/passwd.rb', line 2

def add(name:, uid:, gid:)
  return false unless can_add?(name, uid)
  @new_records[name] = { uid: uid, gid: gid }

  true
end

#build_new_recordsObject



9
10
11
# File 'lib/unix_user_manager/file/passwd.rb', line 9

def build_new_records
  @new_records.map { |name, data| "#{name}:x:#{data[:uid]}:#{data[:gid]}::/dev/null:/bin/bash" }.join("\n")
end