Module: ActiveSambaLdap::GroupEntry

Included in:
Group
Defined in:
lib/active_samba_ldap/group_entry.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
# File 'lib/active_samba_ldap/group_entry.rb', line 7

def self.included(base)
  super
  base.extend(ClassMethods)
end

Instance Method Details

#change_gid_number(gid, allow_non_unique = false) ⇒ Object



128
129
130
131
# File 'lib/active_samba_ldap/group_entry.rb', line 128

def change_gid_number(gid, allow_non_unique=false)
  check_unique_gid_number(gid) unless allow_non_unique
  self.gid_number = gid
end

#destroy(options = {}) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/active_samba_ldap/group_entry.rb', line 133

def destroy(options={})
  if options[:remove_members]
    if options[:force_change_primary_members]
      change_primary_members(options)
    end
    reload_primary_members
    unless primary_members.empty?
      not_destroyed_members = primary_members.collect {|x| x.uid}
      raise PrimaryGroupCanNotBeDestroyed.new(cn, not_destroyed_members)
    end
    self.users = []
    self.computers = []
  end
  super()
end

#fill_default_values(options = {}) ⇒ Object



103
104
105
106
107
108
# File 'lib/active_samba_ldap/group_entry.rb', line 103

def fill_default_values(options={})
  options = options.stringify_keys
  gid_number = options["gid_number"]
  change_gid_number(gid_number) if gid_number
  self.description ||= options["description"] || cn
end

#membersObject



110
111
112
# File 'lib/active_samba_ldap/group_entry.rb', line 110

def members
  users.to_ary + computers.to_ary
end

#primary_membersObject



119
120
121
# File 'lib/active_samba_ldap/group_entry.rb', line 119

def primary_members
  primary_users.to_ary + primary_computers.to_ary
end

#reload_membersObject



114
115
116
117
# File 'lib/active_samba_ldap/group_entry.rb', line 114

def reload_members
  users.reload
  computers.reload
end

#reload_primary_membersObject



123
124
125
126
# File 'lib/active_samba_ldap/group_entry.rb', line 123

def reload_primary_members
  primary_users.reload
  primary_computers.reload
end