Class: UnixUserManager::File::Group

Inherits:
Base
  • Object
show all
Defined in:
lib/unix_user_manager/file/group.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:, uname:, gid:) ⇒ Object



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

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

  true
end

#build_new_recordsObject



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

def build_new_records
  @new_records.map { |name, data| "#{name}:x:#{data[:gid]}:#{data[:uname]}" }.join("\n")
end