Class: Textus::Application::Write::Reject::Impl
- Inherits:
-
Object
- Object
- Textus::Application::Write::Reject::Impl
- Includes:
- AuthorityGate
- Defined in:
- lib/textus/application/write/reject.rb
Instance Method Summary collapse
- #call(pending_key) ⇒ Object
-
#initialize(ctx:, caps:, writer:, hook_context:) ⇒ Impl
constructor
A new instance of Impl.
Methods included from AuthorityGate
Constructor Details
#initialize(ctx:, caps:, writer:, hook_context:) ⇒ Impl
Returns a new instance of Impl.
18 19 20 21 22 23 24 25 26 |
# File 'lib/textus/application/write/reject.rb', line 18 def initialize(ctx:, caps:, writer:, hook_context:) @ctx = ctx @caps = caps @manifest = caps.manifest @writer = writer @events = caps.events @authorizer = caps. @hook_context = hook_context end |
Instance Method Details
#call(pending_key) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/textus/application/write/reject.rb', line 28 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::Read::Get::Impl.new( ctx: @ctx, caps: @caps, ).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::Write::Delete::Impl.new( ctx: @ctx, caps: @caps, writer: @writer, hook_context: @hook_context ).call(pending_key, suppress_events: true) @events.publish(:proposal_rejected, ctx: @hook_context, key: pending_key, target_key: target_key) { "protocol" => PROTOCOL, "rejected" => pending_key, "target_key" => target_key } end |