Class: Textus::Application::Writes::Reject
- Inherits:
-
Object
- Object
- Textus::Application::Writes::Reject
- Includes:
- AuthorityGate
- Defined in:
- lib/textus/application/writes/reject.rb
Instance Method Summary collapse
- #call(pending_key) ⇒ Object
-
#initialize(ctx:, manifest:, file_store:, envelope_io:, bus:, authorizer:, hook_context:) ⇒ Reject
constructor
rubocop:disable Metrics/ParameterLists.
Methods included from AuthorityGate
Constructor Details
#initialize(ctx:, manifest:, file_store:, envelope_io:, bus:, authorizer:, hook_context:) ⇒ Reject
rubocop:disable Metrics/ParameterLists
9 10 11 12 13 14 15 16 17 |
# File 'lib/textus/application/writes/reject.rb', line 9 def initialize(ctx:, manifest:, file_store:, envelope_io:, bus:, authorizer:, hook_context:) # rubocop:disable Metrics/ParameterLists @ctx = ctx @manifest = manifest @file_store = file_store @envelope_io = envelope_io @bus = bus @authorizer = @hook_context = hook_context end |
Instance Method Details
#call(pending_key) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/textus/application/writes/reject.rb', line 19 def call(pending_key) ("reject") mentry = @manifest.resolver.resolve(pending_key).entry unless mentry.in_proposal_zone? raise ProposalError.new("reject: '#{pending_key}' is not in a proposal zone (zone=#{mentry.zone})") end env = Textus::Application::Reads::Get.new( ctx: @ctx, manifest: @manifest, file_store: @file_store, ).call(pending_key) proposal = env.&.dig("proposal") or raise ProposalError.new("entry has no proposal block: #{pending_key}") target_key = proposal["target_key"] or raise ProposalError.new("proposal missing target_key") Textus::Application::Writes::Delete.new( ctx: @ctx, manifest: @manifest, envelope_io: @envelope_io, bus: @bus, authorizer: @authorizer, hook_context: @hook_context ).call(pending_key, suppress_events: true) @bus.publish(:proposal_rejected, ctx: @hook_context, key: pending_key, target_key: target_key) { "protocol" => PROTOCOL, "rejected" => pending_key, "target_key" => target_key } end |