Class: Textus::Write::Accept
- Inherits:
-
Object
- Object
- Textus::Write::Accept
- Includes:
- AuthorityGate
- Defined in:
- lib/textus/write/accept.rb
Instance Method Summary collapse
- #call(pending_key) ⇒ Object
-
#initialize(container:, call:) ⇒ Accept
constructor
A new instance of Accept.
Methods included from AuthorityGate
Constructor Details
#initialize(container:, call:) ⇒ Accept
Returns a new instance of Accept.
8 9 10 11 12 13 14 |
# File 'lib/textus/write/accept.rb', line 8 def initialize(container:, call:) @container = container @call = call @manifest = container.manifest @schemas = container.schemas @events = container.events end |
Instance Method Details
#call(pending_key) ⇒ Object
16 17 18 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 47 48 49 |
# File 'lib/textus/write/accept.rb', line 16 def call(pending_key) ("accept") env = Textus::Read::Get.new( container: @container, call: @call, ).call(pending_key) proposal = env.["proposal"] or raise ProposalError.new("entry has no proposal block: #{pending_key}") target = proposal["target_key"] or raise ProposalError.new("proposal missing target_key") action = proposal["action"] || "put" evaluate_promotion!(env, target) case action when "put" # Nested proposal "frontmatter" — the meta to write to the accepted # target. Not related to the removed intake-handler legacy bridge. = env.["frontmatter"] || {} target_body = env.body put_op.call(target, meta: , body: target_body) when "delete" delete_op.call(target) else raise ProposalError.new("unknown action: #{action}") end delete_op.call(pending_key) @events.publish(:proposal_accepted, ctx: hook_context, key: pending_key, target_key: target) { "protocol" => PROTOCOL, "accepted" => pending_key, "target_key" => target, "action" => action } end |