Class: Ddr::Auth::Groups
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ddr::Auth::Groups
- Defined in:
- lib/ddr/auth/groups.rb
Constant Summary collapse
- Public =
Group.build("public")
- Registered =
Group.build("registered")
- DukeEppn =
Group.build("duke.all")
- Superusers =
Group.build("superusers")
- CollectionCreators =
Group.build("collection_creators")
- ISMEMBEROF_RE =
Regexp.new('urn:mace:duke\.edu:groups:library:repository:ddr:[\w:]+')
- DUKE_EPPN_RE =
Regexp.new('(?=@duke\.edu)')
- AFFILIATION_RE =
Regexp.new('(%{a})(?=@duke\.edu)' % {a: Affiliation::VALUES.join("|")})
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.all ⇒ Array<Group>
Return the list of all groups available for use in the repository.
- .grouper ⇒ Object
- .remote ⇒ Object
Instance Method Summary collapse
-
#initialize(user, env = nil) ⇒ Groups
constructor
A new instance of Groups.
- #inspect ⇒ Object
-
#names ⇒ Array<String>
Return a list of the group names.
- #to_s ⇒ Object
Constructor Details
#initialize(user, env = nil) ⇒ Groups
Returns a new instance of Groups.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ddr/auth/groups.rb', line 36 def initialize(user, env=nil) @user = user @env = env groups = [ Public ] # everybody if user.persisted? groups << Registered groups << DukeEppn if duke_eppn? groups.concat(remote) groups.concat(affiliation) end super(groups) self << Superusers if names.include?(Ddr::Auth.superuser_group) self << CollectionCreators if names.include?(Ddr::Auth.collection_creators_group) end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
34 35 36 |
# File 'lib/ddr/auth/groups.rb', line 34 def env @env end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
34 35 36 |
# File 'lib/ddr/auth/groups.rb', line 34 def user @user end |
Class Method Details
.all ⇒ Array<Group>
Return the list of all groups available for use in the repository
21 22 23 |
# File 'lib/ddr/auth/groups.rb', line 21 def all Affiliation.groups + remote + [Public, Registered, DukeEppn] end |
Instance Method Details
#inspect ⇒ Object
51 52 53 |
# File 'lib/ddr/auth/groups.rb', line 51 def inspect "#<#{self.class.name} user=\"#{user}\", env=#{env ? '[YES]' : '[NO]'}, groups=#{names.inspect}>" end |
#names ⇒ Array<String>
Return a list of the group names
61 62 63 |
# File 'lib/ddr/auth/groups.rb', line 61 def names map(&:to_s) end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/ddr/auth/groups.rb', line 55 def to_s names.to_s end |