Class: Textus::Surfaces::RoleScope

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/surfaces/role_scope.rb

Overview

Role-scoped identity carrier. Holds the acting identity (role, correlation_id, dry_run) bound to a container. All verb methods (put, get, accept, …) are injected by textus.rb’s define_method loop, which dispatches directly through Gate.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container:, role:, dry_run: false, correlation_id: nil) ⇒ RoleScope

Returns a new instance of RoleScope.



12
13
14
15
16
17
# File 'lib/textus/surfaces/role_scope.rb', line 12

def initialize(container:, role:, dry_run: false, correlation_id: nil)
  @container      = container
  @role           = role.to_s
  @dry_run        = dry_run
  @correlation_id = correlation_id || SecureRandom.uuid
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



10
11
12
# File 'lib/textus/surfaces/role_scope.rb', line 10

def container
  @container
end

#correlation_idObject (readonly)

Returns the value of attribute correlation_id.



10
11
12
# File 'lib/textus/surfaces/role_scope.rb', line 10

def correlation_id
  @correlation_id
end

#roleObject (readonly)

Returns the value of attribute role.



10
11
12
# File 'lib/textus/surfaces/role_scope.rb', line 10

def role
  @role
end

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


19
# File 'lib/textus/surfaces/role_scope.rb', line 19

def dry_run? = !!@dry_run

#hook_contextObject



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

def hook_context
  @hook_context ||= Textus::Step::Context.new(scope: self)
end

#with_correlation_id(cid) ⇒ Object



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

def with_correlation_id(cid)
  self.class.new(container: @container, role: @role, dry_run: @dry_run, correlation_id: cid)
end

#with_dry_runObject



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

def with_dry_run
  self.class.new(container: @container, role: @role, dry_run: true, correlation_id: @correlation_id)
end

#with_role(role) ⇒ Object



21
22
23
# File 'lib/textus/surfaces/role_scope.rb', line 21

def with_role(role)
  self.class.new(container: @container, role:, dry_run: @dry_run, correlation_id: @correlation_id)
end