Class: Textus::Operations

Inherits:
Object
  • Object
show all
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)
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx) ⇒ Operations

Returns a new instance of Operations.



24
25
26
# File 'lib/textus/operations.rb', line 24

def initialize(ctx)
  @ctx = ctx
end

Instance Attribute Details

#ctxObject (readonly)

Returns the value of attribute ctx.



22
23
24
# File 'lib/textus/operations.rb', line 22

def ctx
  @ctx
end

Class Method Details

.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/textus/operations.rb', line 12

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

#readsObject



32
33
34
# File 'lib/textus/operations.rb', line 32

def reads
  @reads ||= Reads.new(@ctx)
end

#refreshObject



36
37
38
# File 'lib/textus/operations.rb', line 36

def refresh
  @refresh ||= Refresh.new(@ctx)
end

#with_role(role) ⇒ Object



40
41
42
# File 'lib/textus/operations.rb', line 40

def with_role(role)
  self.class.new(@ctx.with_role(role))
end

#writesObject



28
29
30
# File 'lib/textus/operations.rb', line 28

def writes
  @writes ||= Writes.new(@ctx)
end