Class: Textus::Action::Reject

Inherits:
Base
  • Object
show all
Defined in:
lib/textus/action/reject.rb

Class Method Summary collapse

Methods inherited from Base

inherited, proposal_from

Methods included from Contract::DSL

#arg, #cli, #cli_stdin, #contract, #contract?, #summary, #surfaces, #verb, #view

Class Method Details

.call(container:, call:, pending_key:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/textus/action/reject.rb', line 12

def self.call(container:, call:, pending_key:)
  mentry = container.manifest.resolver.resolve(pending_key).entry
  unless mentry.in_proposal_lane?(container.manifest.policy)
    return Failure(code: :proposal_error, message: "reject: '#{pending_key}' is not in a proposal zone (zone=#{mentry.lane})")
  end

  env = container.compositor.read(pending_key)
  parsed = proposal_from(env, key: pending_key)
  return parsed if parsed.is_a?(Dry::Monads::Result::Failure)

  target_key = parsed[:target_key]
  container.compositor.delete(pending_key, mentry: mentry, call: call)
  Success("protocol" => Textus::PROTOCOL, "rejected" => pending_key, "target_key" => target_key)
end