class OodCore::Acl::Adapters::Group
An adapter object that describes a group permission ACL
Public Class Methods
new(opts)
click to toggle source
@api private @param opts [#to_h] the options defining this adapter @option opts [OodSupport::ACL] :acl The ACL permission @option opts [Boolean] :allow (true) Whether this ACL allows access @see Factory.build_group
# File lib/ood_core/acl/adapters/group.rb, line 41 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
Public Instance Methods
allow?()
click to toggle source
Whether this ACL allows the active user access based on their groups @return [Boolean] whether principle is allowed
# File lib/ood_core/acl/adapters/group.rb, line 49 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