Class: Textus::Manifest::Policy::Predicates::RawLaneIngestOnly

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

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

  mentry = manifest.resolver.resolve(key).entry
  return { pass: true } unless manifest.policy.declared_kind(mentry.lane.to_s) == :raw
  return { pass: true } if action == :ingest

  { pass: false, error: Textus::Error.new(
    :raw_lane_ingest_only,
    "raw lane '#{mentry.lane}' only accepts `textus ingest` — " \
    "use that verb instead of '#{action}'",
  ) }
rescue Textus::UnknownKey
  { pass: true }
end