Skip to content

Commit

Permalink
get user groups only when requested
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Nicklas committed Jun 30, 2016
1 parent 611890b commit e7a110e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/ood_support/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,9 @@ class User

alias_method :id, :uid

# List of all groups that user belongs to
# @return [Array<String>] list of groups user is in
attr_reader :groups

# @param user [Fixnum, #to_s] user id or name
def initialize(user = Process.user)
@passwd = user.is_a?(Fixnum) ? Etc.getpwuid(user) : Etc.getpwnam(user.to_s)
@groups = get_groups
end

# Determine whether user is part of specified group
Expand All @@ -51,6 +46,12 @@ def group
groups.first
end

# List of all groups that user belongs to
# @return [Array<String>] list of groups user is in
def groups
@groups ||= get_groups
end

# The comparison operator for sorting values
# @param other [User] user to compare against
# @return [Fixnum] how users compare
Expand Down

0 comments on commit e7a110e

Please sign in to comment.