Class: Textus::Manifest::Policy::Predicates::EtagMatch

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/manifest/policy/predicates/etag_match.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
# File 'lib/textus/manifest/policy/predicates/etag_match.rb', line 6

def self.call(manifest:, actor:, action:, key:, schemas: nil, envelope: nil, extra: {})
  if_etag = extra[:if_etag]
  return { pass: true } if if_etag.nil?

  current = envelope&.etag
  pass = current.nil? || current == if_etag
  { pass:, error: pass ? nil : Textus::EtagMismatch.new(key, if_etag, current) }
end