Class: Textus::Application::Writes::Reject
- Inherits:
-
Object
- Object
- Textus::Application::Writes::Reject
- Defined in:
- lib/textus/application/writes/reject.rb
Instance Method Summary collapse
- #call(pending_key) ⇒ Object
-
#initialize(ctx:, bus:) ⇒ Reject
constructor
A new instance of Reject.
Constructor Details
#initialize(ctx:, bus:) ⇒ Reject
Returns a new instance of Reject.
5 6 7 8 |
# File 'lib/textus/application/writes/reject.rb', line 5 def initialize(ctx:, bus:) @ctx = ctx @bus = bus end |
Instance Method Details
#call(pending_key) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/textus/application/writes/reject.rb', line 10 def call(pending_key) raise ProposalError.new("only human role can reject proposals; got '#{@ctx.role}'") unless @ctx.role == "human" mentry, = @ctx.store.manifest.resolve(pending_key) unless mentry.in_proposal_zone? raise ProposalError.new("reject: '#{pending_key}' is not in a proposal zone (zone=#{mentry.zone})") end env = @ctx.store.reader.get(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, bus: @bus).call(pending_key, suppress_events: true) @bus.publish(:proposal_rejected, store: @ctx.with_role(@ctx.role), key: pending_key, target_key: target_key, correlation_id: @ctx.correlation_id) { "protocol" => PROTOCOL, "rejected" => pending_key, "target_key" => target_key } end |