Class: Treaty::Action::Versions::Executor

Inherits:
Object
  • Object
show all
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_to is 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

Instance Method Summary collapse

Constructor Details

#initialize(executor, method) ⇒ Executor

Creates a new executor value object

Parameters:

  • executor (Class, String, Proc)

    Service reference

  • method (Symbol)

    Method to invoke (default: :call)



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

#executorClass, ... (readonly)

Returns Service class, path string, or proc.

Returns:

  • (Class, String, Proc)

    Service class, path string, or proc



45
46
47
# File 'lib/treaty/action/versions/executor.rb', line 45

def executor
  @executor
end

#methodSymbol (readonly)

Returns Method name to call on executor.

Returns:

  • (Symbol)

    Method name to call on executor



48
49
50
# File 'lib/treaty/action/versions/executor.rb', line 48

def method
  @method
end