Class: Textus::Operations
- Inherits:
-
Object
- Object
- Textus::Operations
- Defined in:
- lib/textus/operations.rb,
lib/textus/operations/reads.rb,
lib/textus/operations/writes.rb,
lib/textus/operations/refresh.rb
Overview
Single canonical entrypoint for invoking application use-cases against a store. Mirrors the directory structure under ‘lib/textus/application/`:
ops = Textus::Operations.for(store, role: "agent")
ops.writes.put.call(key, body: "...")
ops.reads.get.call(key) # pure read
ops.reads.get_or_refresh.call(key) # read + refresh-on-stale
ops.refresh.worker.call(key)
Replaces the prior ‘Textus::Composition` module (deleted in v0.12.2).
Defined Under Namespace
Classes: Reads, Refresh, Writes
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ctx) ⇒ Operations
constructor
A new instance of Operations.
- #reads ⇒ Object
- #refresh ⇒ Object
- #with_role(role) ⇒ Object
- #writes ⇒ Object
Constructor Details
#initialize(ctx) ⇒ Operations
Returns a new instance of Operations.
25 26 27 |
# File 'lib/textus/operations.rb', line 25 def initialize(ctx) @ctx = ctx end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
23 24 25 |
# File 'lib/textus/operations.rb', line 23 def ctx @ctx end |
Class Method Details
.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/textus/operations.rb', line 13 def self.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false) ctx = Application::Context.new( store: store, role: role, correlation_id: correlation_id, dry_run: dry_run, ) new(ctx) end |
Instance Method Details
#reads ⇒ Object
33 34 35 |
# File 'lib/textus/operations.rb', line 33 def reads @reads ||= Reads.new(@ctx) end |
#refresh ⇒ Object
37 38 39 |
# File 'lib/textus/operations.rb', line 37 def refresh @refresh ||= Refresh.new(@ctx) end |
#with_role(role) ⇒ Object
41 42 43 |
# File 'lib/textus/operations.rb', line 41 def with_role(role) self.class.new(@ctx.with_role(role)) end |