Class: Textus::Application::Policy::Predicates::HumanAccept

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/application/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/application/policy/predicates/human_accept.rb', line 6

def reason
  @reason
end

Instance Method Details

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

The role is passed explicitly. 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.



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

def call(role:, entry: nil) # rubocop:disable Lint/UnusedMethodArgument
  role_str = role&.to_s
  # If we cannot determine the role, trust that Accept has already
  # checked — allow through.
  return true if role_str.nil? || role_str.empty?

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

#nameObject



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

def name
  "human_accept"
end