Class: Textus::Domain::Policy::Predicates::HumanAccept

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/domain/policy/predicates/human_accept.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



6
7
8
# File 'lib/textus/domain/policy/predicates/human_accept.rb', line 6

def reason
  @reason
end

Instance Method Details

#call(store:, entry: nil) ⇒ Object

The role is passed via ‘store` (an Application::Context-like object with a `role` reader) or through the entry metadata. In practice, Accept already enforces role == “human” before reaching the promotion gate, so this predicate trivially passes. It documents intent and future-proofs multi-actor accept flows.



17
18
19
20
21
22
23
24
25
26
# File 'lib/textus/domain/policy/predicates/human_accept.rb', line 17

def call(store:, entry: nil) # rubocop:disable Lint/UnusedMethodArgument
  role = store.respond_to?(:role) ? store.role.to_s : nil
  # If we cannot determine the role (e.g. store doesn't expose it),
  # we trust that Accept has already checked — allow through.
  return true if role.nil?

  ok = (role == "human")
  @reason = "current role is '#{role}', expected 'human'" unless ok
  ok
end

#nameObject



8
9
10
# File 'lib/textus/domain/policy/predicates/human_accept.rb', line 8

def name
  "human_accept"
end