Class: Treaty::Action::Versions::Executor
- Inherits:
-
Object
- Object
- Treaty::Action::Versions::Executor
- Defined in:
- lib/treaty/action/versions/executor.rb
Overview
Value object holding executor reference and method name.
Purpose
Stores the service class/proc and method name configured via
delegate_to in version definitions. Separates executor
configuration from execution logic.
Usage
Created by:
- Versions::Factory (when
delegate_tois called)
Consumed by:
- Versions::Execution::Request (to execute the service)
Executor Types
The executor attribute can hold:
- Class reference:
Posts::CreateService - String path:
"posts/create_service" - Proc/Lambda:
->(params:) { ... }
Method Attribute
The method attribute specifies which method to call:
- Default:
:call - Custom: specified via hash syntax
delegate_to Service => :perform
Example
# In version definition:
delegate_to Posts::CreateService # method defaults to :call
delegate_to Posts::CreateService => :call! # explicit method
# Creates:
Executor.new(Posts::CreateService, :call)
Instance Attribute Summary collapse
-
#executor ⇒ Class, ...
readonly
Service class, path string, or proc.
-
#method ⇒ Symbol
readonly
Method name to call on executor.
Instance Method Summary collapse
-
#initialize(executor, method) ⇒ Executor
constructor
Creates a new executor value object.
Constructor Details
#initialize(executor, method) ⇒ Executor
Creates a new executor value object
54 55 56 57 |
# File 'lib/treaty/action/versions/executor.rb', line 54 def initialize(executor, method) @executor = executor @method = method end |
Instance Attribute Details
#executor ⇒ Class, ... (readonly)
Returns Service class, path string, or proc.
45 46 47 |
# File 'lib/treaty/action/versions/executor.rb', line 45 def executor @executor end |
#method ⇒ Symbol (readonly)
Returns Method name to call on executor.
48 49 50 |
# File 'lib/treaty/action/versions/executor.rb', line 48 def method @method end |