Class: Textus::Action::Reject
- Extended by:
- Contract::DSL
- Defined in:
- lib/textus/action/reject.rb
Instance Method Summary collapse
- #call(container:, call:) ⇒ Object
-
#initialize(pending_key:) ⇒ Reject
constructor
A new instance of Reject.
Methods included from Contract::DSL
arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view
Methods inherited from Base
Constructor Details
#initialize(pending_key:) ⇒ Reject
Returns a new instance of Reject.
14 15 16 17 |
# File 'lib/textus/action/reject.rb', line 14 def initialize(pending_key:) super() @pending_key = pending_key end |
Instance Method Details
#call(container:, call:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/textus/action/reject.rb', line 19 def call(container:, call:) run_with_cascade(@pending_key, container:, call:) do mentry = container.manifest.resolver.resolve(@pending_key).entry unless mentry.in_proposal_lane?(container.manifest.policy) raise ProposalError.new("reject: '#{@pending_key}' is not in a proposal zone (zone=#{mentry.lane})") end env = Textus::Action::Get.new(key: @pending_key).call(container: container, call: call) 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") writer(container, call).delete(@pending_key, mentry: mentry) { "protocol" => PROTOCOL, "rejected" => @pending_key, "target_key" => target_key } end end |