Class: Textus::Hooks::Context
- Inherits:
-
Object
- Object
- Textus::Hooks::Context
- Defined in:
- lib/textus/hooks/context.rb
Overview
A narrow handle passed to user hooks in place of the raw Store. All writes route back through Operations so authorization, audit logging, and schema validation always fire.
Instance Attribute Summary collapse
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
- #audit(verb, key:) ⇒ Object
- #delete(key) ⇒ Object
- #deps(key) ⇒ Object
- #freshness(key) ⇒ Object
-
#get(key) ⇒ Object
read.
-
#initialize(ops:) ⇒ Context
constructor
A new instance of Context.
- #inspect ⇒ Object
- #list ⇒ Object
-
#publish_followup(event) ⇒ Object
fan-out.
-
#put(key) ⇒ Object
write (authorized + audited).
Constructor Details
#initialize(ops:) ⇒ Context
Returns a new instance of Context.
11 12 13 14 15 |
# File 'lib/textus/hooks/context.rb', line 11 def initialize(ops:) @ops = ops @role = ops.ctx.role @correlation_id = ops.ctx.correlation_id end |
Instance Attribute Details
#correlation_id ⇒ Object (readonly)
Returns the value of attribute correlation_id.
9 10 11 |
# File 'lib/textus/hooks/context.rb', line 9 def correlation_id @correlation_id end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
9 10 11 |
# File 'lib/textus/hooks/context.rb', line 9 def role @role end |
Instance Method Details
#audit(verb, key:) ⇒ Object
26 |
# File 'lib/textus/hooks/context.rb', line 26 def audit(verb, key:, **) = @ops.store.audit_log.append(role: @role, verb: verb, key: key, **) |
#delete(key) ⇒ Object
25 |
# File 'lib/textus/hooks/context.rb', line 25 def delete(key, **) = @ops.delete(key, **) |
#deps(key) ⇒ Object
20 |
# File 'lib/textus/hooks/context.rb', line 20 def deps(key) = @ops.deps(key) |
#freshness(key) ⇒ Object
21 |
# File 'lib/textus/hooks/context.rb', line 21 def freshness(key) = @ops.freshness(key) |
#get(key) ⇒ Object
read
18 |
# File 'lib/textus/hooks/context.rb', line 18 def get(key) = @ops.get(key) |
#inspect ⇒ Object
33 34 35 |
# File 'lib/textus/hooks/context.rb', line 33 def inspect "#<Textus::Hooks::Context role=#{@role} correlation_id=#{@correlation_id}>" end |
#list ⇒ Object
19 |
# File 'lib/textus/hooks/context.rb', line 19 def list(**) = @ops.list(**) |
#publish_followup(event) ⇒ Object
fan-out
29 30 31 |
# File 'lib/textus/hooks/context.rb', line 29 def publish_followup(event, **) @ops.store.bus.publish(event, ctx: self, **) end |
#put(key) ⇒ Object
write (authorized + audited)
24 |
# File 'lib/textus/hooks/context.rb', line 24 def put(key, **) = @ops.put(key, **) |