Class: Textus::Call

Inherits:
Data
  • Object
show all
Defined in:
lib/textus/call.rb

Overview

Immutable per-invocation value. Carries who is acting (role), the request correlation id, the wall clock, and the dry_run flag — the bits Use Cases need that are not part of the Container.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#correlation_idObject (readonly)

Returns the value of attribute correlation_id

Returns:

  • (Object)

    the current value of correlation_id



7
8
9
# File 'lib/textus/call.rb', line 7

def correlation_id
  @correlation_id
end

#dry_runObject (readonly)

Returns the value of attribute dry_run

Returns:

  • (Object)

    the current value of dry_run



7
8
9
# File 'lib/textus/call.rb', line 7

def dry_run
  @dry_run
end

#nowObject (readonly)

Returns the value of attribute now

Returns:

  • (Object)

    the current value of now



7
8
9
# File 'lib/textus/call.rb', line 7

def now
  @now
end

#roleObject (readonly)

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



7
8
9
# File 'lib/textus/call.rb', line 7

def role
  @role
end

Class Method Details

.build(role:, correlation_id: nil, now: nil, dry_run: false) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/textus/call.rb', line 8

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 || Textus::Ports::Clock.now,
    dry_run: dry_run,
  )
end

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


17
# File 'lib/textus/call.rb', line 17

def dry_run? = dry_run

#with_role(new_role) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/textus/call.rb', line 19

def with_role(new_role)
  self.class.new(
    role: new_role.to_s,
    correlation_id: correlation_id,
    now: now,
    dry_run: dry_run,
  )
end