Class: OodCore::Acl::Adapters::Group
- Inherits:
-
OodCore::Acl::Adapter
- Object
- OodCore::Acl::Adapter
- OodCore::Acl::Adapters::Group
- Defined in:
- lib/ood_core/acl/adapters/group.rb
Overview
An adapter object that describes a group permission ACL
Instance Method Summary collapse
-
#allow? ⇒ Boolean
Whether this ACL allows the active user access based on their groups.
-
#initialize(opts) ⇒ Group
constructor
private
A new instance of Group.
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.
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
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 |