Class: Textus::Manifest::Policy::Predicates::AuthorHeld

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/manifest/policy/predicates/author_held.rb

Class Method Summary collapse

Class Method Details

.call(manifest:, actor:, action:, key:, schemas: nil, envelope: nil, extra: {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/textus/manifest/policy/predicates/author_held.rb', line 6

def self.call(manifest:, actor:, action:, key:, schemas: nil, envelope: nil, extra: {})
  holders = manifest.policy.roles_with_capability("author")
  pass = holders.include?(actor.to_s)
  reason = if pass
             nil
           elsif holders.empty?
             "no role holds the 'author' capability; #{action} is disabled"
           else
             "role '#{actor}' lacks the 'author' capability (held by: #{holders.join(", ")})"
           end
  { pass:, reason: }
end