Module: Textus::Application::Writes::AuthorityGate

Included in:
Accept, Reject
Defined in:
lib/textus/application/writes/authority_gate.rb

Overview

Shared gate for write verbs that require the caller to hold the manifest’s accept_authority role. Provides one method, expressed as two early-returns rather than a ternary, so each failure mode reads on its own line.

Instance Method Summary collapse

Instance Method Details

#assert_accept_authority!(verb) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/textus/application/writes/authority_gate.rb', line 9

def assert_accept_authority!(verb)
  return if @manifest.role_kind(@ctx.role) == :accept_authority

  authority = @manifest.roles_with_kind(:accept_authority).first
  if authority.nil?
    raise ProposalError.new(
      "no role with accept_authority kind is declared in this manifest; #{verb} is disabled",
    )
  end

  raise ProposalError.new(
    "only #{authority} role can #{verb} proposals; got '#{@ctx.role}'",
  )
end