Class: GitWit::Actions::Dscl::GroupMembership

Inherits:
Base
  • Object
show all
Defined in:
lib/git_wit/actions/dscl/group_membership.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#base, #name, #type

Instance Method Summary collapse

Methods inherited from Base

#invoke!, #revoke!

Constructor Details

#initialize(base, user, group, config = {}) ⇒ GroupMembership

Returns a new instance of GroupMembership.



5
6
7
8
# File 'lib/git_wit/actions/dscl/group_membership.rb', line 5

def initialize(base, user, group, config = {})
  super base, :group_membership, "#{user} #{group}", config
  @user, @group = user, group
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



3
4
5
# File 'lib/git_wit/actions/dscl/group_membership.rb', line 3

def group
  @group
end

#userObject (readonly)

Returns the value of attribute user.



3
4
5
# File 'lib/git_wit/actions/dscl/group_membership.rb', line 3

def user
  @user
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/git_wit/actions/dscl/group_membership.rb', line 10

def exists?
  check = `dsmemberutil checkmembership -U '#{user}' -G '#{group}' 2>/dev/null`
  $?.success? && !!(check =~ /is a member/)
end