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.



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

def initialize(ctx)
  @ctx = ctx
end

Instance Attribute Details

#ctxObject (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, bypass_freshness: false) ⇒ Object



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

def self.for(store, role: Role::DEFAULT, correlation_id: nil, dry_run: false, bypass_freshness: false)
  ctx = Application::Context.new(
    store: store,
    role: role,
    correlation_id: correlation_id,
    dry_run: dry_run,
    bypass_freshness: bypass_freshness,
  )
  new(ctx)
end

Instance Method Details

#readsObject



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

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

#refreshObject



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

#writesObject



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

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