Class: Textus::RoleScope
- Inherits:
-
Object
- Object
- Textus::RoleScope
- Defined in:
- lib/textus/role_scope.rb
Overview
Thin role-scoped facade over a Container. Closes over a role default and a dry_run flag, then forwards every verb in Dispatcher::VERBS to the corresponding use case.
Replaces the per-call Session under the 0.27.0 architecture: a Store exposes #as(role) to get a RoleScope, and Store#put / Store#get / etc delegate to RoleScope under the default role.
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.
16 17 18 19 20 21 |
# File 'lib/textus/role_scope.rb', line 16 def initialize(container:, role:, dry_run: false, correlation_id: nil) @container = container @role = role.to_s @dry_run = dry_run @correlation_id = correlation_id end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
10 11 12 |
# File 'lib/textus/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/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/role_scope.rb', line 10 def role @role end |
Instance Method Details
#dry_run? ⇒ Boolean
12 13 14 |
# File 'lib/textus/role_scope.rb', line 12 def dry_run? @dry_run end |
#hook_context ⇒ Object
31 32 33 |
# File 'lib/textus/role_scope.rb', line 31 def hook_context @hook_context ||= Textus::Hooks::Context.new(scope: self) end |
#with_correlation_id(cid) ⇒ Object
27 28 29 |
# File 'lib/textus/role_scope.rb', line 27 def with_correlation_id(cid) self.class.new(container: @container, role: @role, dry_run: @dry_run, correlation_id: cid) end |
#with_dry_run ⇒ Object
35 36 37 |
# File 'lib/textus/role_scope.rb', line 35 def with_dry_run self.class.new(container: @container, role: @role, dry_run: true, correlation_id: @correlation_id) end |
#with_role(role) ⇒ Object
23 24 25 |
# File 'lib/textus/role_scope.rb', line 23 def with_role(role) self.class.new(container: @container, role: role, dry_run: @dry_run, correlation_id: @correlation_id) end |