Class: OodCore::Acl::Adapters::Group

Inherits:
OodCore::Acl::Adapter show all
Defined in:
lib/ood_core/acl/adapters/group.rb

Overview

An adapter object that describes a group permission ACL

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Group

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Group.

Parameters:

  • opts (#to_h)

    the options defining this adapter

Options Hash (opts):

  • :acl (OodSupport::ACL)

    The ACL permission

  • :allow (Boolean) — default: true

    Whether this ACL allows access

See Also:



42
43
44
45
46
# File 'lib/ood_core/acl/adapters/group.rb', line 42

def initialize(opts)
  o = opts.to_h.symbolize_keys
  @acl = o.fetch(:acl) { raise ArgumentError, "No acl specified. Missing argument: acl" }
  @allow = o.fetch(:allow, true)
end

Instance Method Details

#allow?Boolean

Whether this ACL allows the active user access based on their groups

Returns:

  • (Boolean)

    whether principle is allowed



50
51
52
53
54
55
56
# File 'lib/ood_core/acl/adapters/group.rb', line 50

def allow?
  if @allow
    OodSupport::User.new.groups.map(&:to_s).any? { |g| @acl.allow?(principle: g) }
  else
    OodSupport::User.new.groups.map(&:to_s).none? { |g| @acl.allow?(principle: g) }
  end
end