Class: Textus::Application::Context
- Inherits:
-
Data
- Object
- Data
- Textus::Application::Context
- Defined in:
- lib/textus/application/context.rb
Overview
A Context describes the call: who is acting (role), what request this is part of (correlation_id), what time it is (now), and whether writes should be suppressed (dry_run).
Collaborators (manifest, file_store, bus, audit log, authorizer) are never read from Context — use cases declare them as explicit constructor ports, and Operations wires them in from the Store.
Instance Attribute Summary collapse
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#now ⇒ Object
readonly
Returns the value of attribute now.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#correlation_id ⇒ Object (readonly)
Returns the value of attribute correlation_id
12 13 14 |
# File 'lib/textus/application/context.rb', line 12 def correlation_id @correlation_id end |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run
12 13 14 |
# File 'lib/textus/application/context.rb', line 12 def dry_run @dry_run end |
#now ⇒ Object (readonly)
Returns the value of attribute now
12 13 14 |
# File 'lib/textus/application/context.rb', line 12 def now @now end |
#role ⇒ Object (readonly)
Returns the value of attribute role
12 13 14 |
# File 'lib/textus/application/context.rb', line 12 def role @role end |
Class Method Details
.build(role:, correlation_id: nil, now: nil, dry_run: false) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/textus/application/context.rb', line 13 def self.build(role:, correlation_id: nil, now: nil, dry_run: false) new( role: role.to_s, correlation_id: correlation_id || SecureRandom.uuid, now: now || Time.now, dry_run: dry_run, ) end |
Instance Method Details
#dry_run? ⇒ Boolean
22 |
# File 'lib/textus/application/context.rb', line 22 def dry_run? = dry_run |
#with_role(new_role) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/textus/application/context.rb', line 24 def with_role(new_role) self.class.new( role: new_role.to_s, correlation_id: correlation_id, now: now, dry_run: dry_run, ) end |