Class: Textus::Surfaces::RoleScope
- Inherits:
-
Object
- Object
- Textus::Surfaces::RoleScope
- 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
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#correlation_id ⇒ Object
readonly
Returns the value of attribute correlation_id.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Instance Method Summary collapse
- #dry_run? ⇒ Boolean
- #hook_context ⇒ Object
-
#initialize(container:, role:, dry_run: false, correlation_id: nil) ⇒ RoleScope
constructor
A new instance of RoleScope.
- #with_correlation_id(cid) ⇒ Object
- #with_dry_run ⇒ Object
- #with_role(role) ⇒ Object
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
#container ⇒ Object (readonly)
Returns the value of attribute container.
10 11 12 |
# File 'lib/textus/surfaces/role_scope.rb', line 10 def container @container end |
#correlation_id ⇒ Object (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 |
#role ⇒ Object (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
19 |
# File 'lib/textus/surfaces/role_scope.rb', line 19 def dry_run? = !!@dry_run |
#hook_context ⇒ Object
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_run ⇒ Object
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 |