Class: Wright::Resource::Group

Inherits:
Wright::Resource show all
Defined in:
lib/wright/resource/group.rb

Overview

TODO:

Use GnuPasswd provider on all GNU-flavoured systems

Group resource, represents a group.

Examples:

admins = Wright::Resource::Group.new('admins')
admins.members = ['root']
admins.create

Instance Attribute Summary collapse

Attributes inherited from Wright::Resource

#action, #ignore_failure, #name, #resource_name

Instance Method Summary collapse

Methods inherited from Wright::Resource

#on_update=, #run_action

Constructor Details

#initialize(name) ⇒ Group

Initializes a Group.

Parameters:

  • name (String)

    the group’s name



27
28
29
30
31
# File 'lib/wright/resource/group.rb', line 27

def initialize(name)
  super
  @action = :create
  @system = false
end

Instance Attribute Details

#gidInteger

Returns the group’s intended group id.

Returns:

  • (Integer)

    the group’s intended group id



18
19
20
# File 'lib/wright/resource/group.rb', line 18

def gid
  @gid
end

#membersArray<String>

Returns the group’s intended members.

Returns:

  • (Array<String>)

    the group’s intended members



15
16
17
# File 'lib/wright/resource/group.rb', line 15

def members
  @members
end

#systemBool

Returns true if the group should be a system group. Ignored if #gid is set.

Returns:

  • (Bool)

    true if the group should be a system group. Ignored if #gid is set.



22
23
24
# File 'lib/wright/resource/group.rb', line 22

def system
  @system
end

Instance Method Details

#createBool

Creates or updates the group.

Returns:

  • (Bool)

    true if the group was updated and false otherwise



37
38
39
40
41
# File 'lib/wright/resource/group.rb', line 37

def create
  might_update_resource do
    @provider.create
  end
end

#removeBool

Removes the group.

Returns:

  • (Bool)

    true if the group was updated and false otherwise



47
48
49
50
51
# File 'lib/wright/resource/group.rb', line 47

def remove
  might_update_resource do
    @provider.remove
  end
end