Class: Textus::Session
- Inherits:
-
Object
- Object
- Textus::Session
- Defined in:
- lib/textus/session.rb
Overview
Per-call session. Holds ctx (role, correlation_id, now, dry_run) and the three caps records. Generates one method per registered use case.
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#hook_caps ⇒ Object
readonly
Returns the value of attribute hook_caps.
-
#read_caps ⇒ Object
readonly
Returns the value of attribute read_caps.
-
#write_caps ⇒ Object
readonly
Returns the value of attribute write_caps.
Class Method Summary collapse
Instance Method Summary collapse
- #boot ⇒ Object
- #doctor ⇒ Object
- #envelope_reader ⇒ Object
- #envelope_writer ⇒ Object
- #events ⇒ Object
- #hook_context ⇒ Object
-
#initialize(ctx:, read_caps:, write_caps:, hook_caps:) ⇒ Session
constructor
A new instance of Session.
- #refresh_orchestrator ⇒ Object
- #refresh_worker ⇒ Object
- #rpc ⇒ Object
- #with_role(role) ⇒ Object
Constructor Details
#initialize(ctx:, read_caps:, write_caps:, hook_caps:) ⇒ Session
Returns a new instance of Session.
15 16 17 18 19 20 |
# File 'lib/textus/session.rb', line 15 def initialize(ctx:, read_caps:, write_caps:, hook_caps:) @ctx = ctx @read_caps = read_caps @write_caps = write_caps @hook_caps = hook_caps end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
5 6 7 |
# File 'lib/textus/session.rb', line 5 def ctx @ctx end |
#hook_caps ⇒ Object (readonly)
Returns the value of attribute hook_caps.
5 6 7 |
# File 'lib/textus/session.rb', line 5 def hook_caps @hook_caps end |
#read_caps ⇒ Object (readonly)
Returns the value of attribute read_caps.
5 6 7 |
# File 'lib/textus/session.rb', line 5 def read_caps @read_caps end |
#write_caps ⇒ Object (readonly)
Returns the value of attribute write_caps.
5 6 7 |
# File 'lib/textus/session.rb', line 5 def write_caps @write_caps end |
Class Method Details
.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/textus/session.rb', line 7 def self.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false) read_caps, write_caps, hook_caps = Application.caps_from_store(store) new( ctx: Application::Context.build(role: role, correlation_id: correlation_id, dry_run: dry_run), read_caps: read_caps, write_caps: write_caps, hook_caps: hook_caps ) end |
Instance Method Details
#boot ⇒ Object
50 |
# File 'lib/textus/session.rb', line 50 def boot(...) = Textus::Boot.run(self, ...) |
#doctor ⇒ Object
51 |
# File 'lib/textus/session.rb', line 51 def doctor(...) = Textus::Doctor.run(self, ...) |
#envelope_reader ⇒ Object
36 37 38 39 40 |
# File 'lib/textus/session.rb', line 36 def envelope_reader @envelope_reader ||= Application::Envelope::Reader.new( file_store: @read_caps.file_store, manifest: @read_caps.manifest, ) end |
#envelope_writer ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/textus/session.rb', line 42 def envelope_writer @envelope_writer ||= Application::Envelope::Writer.new( file_store: @write_caps.file_store, manifest: @write_caps.manifest, schemas: @write_caps.schemas, audit_log: @write_caps.audit_log, ctx: @ctx, reader: envelope_reader ) end |
#events ⇒ Object
34 |
# File 'lib/textus/session.rb', line 34 def events = @hook_caps.events |
#hook_context ⇒ Object
29 30 31 |
# File 'lib/textus/session.rb', line 29 def hook_context @hook_context ||= Hooks::Context.new(session: self) end |
#refresh_orchestrator ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/textus/session.rb', line 53 def refresh_orchestrator @refresh_orchestrator ||= Application::Write::RefreshOrchestrator.new( worker: refresh_worker, store_root: @write_caps.root, events: @write_caps.events, ctx: @ctx, hook_context: hook_context, ) end |
#refresh_worker ⇒ Object
63 64 65 66 67 68 |
# File 'lib/textus/session.rb', line 63 def refresh_worker @refresh_worker ||= Application::Write::RefreshWorker::Impl.new( ctx: @ctx, caps: @write_caps, rpc: rpc, writer: envelope_writer, hook_context: hook_context ) end |
#rpc ⇒ Object
33 |
# File 'lib/textus/session.rb', line 33 def rpc = @hook_caps.rpc |
#with_role(role) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/textus/session.rb', line 22 def with_role(role) self.class.new( ctx: @ctx.with_role(role), read_caps: @read_caps, write_caps: @write_caps, hook_caps: @hook_caps ) end |