Module: ExcADG::Payload

Overview

module to base payload for Vertex -es on it, reason for having this special module to provider simple labmdas is that Ractor (which is a base for Vertex) require its parameters scope to be shareable

Defined Under Namespace

Modules: Example, Wrapper Classes: IncorrectPayloadArity, NoPayloadSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argsObject

Returns the value of attribute args.



9
10
11
# File 'lib/excadg/payload.rb', line 9

def args
  @args
end

Instance Method Details

#getProc

main method of the payload that holds code to be executed within vertex, vertex takes care of error processing - there is no need to mask exceptions, this method should return a Proc, that:

  • could receive up to 1 arguments

  • 1st argument, if specified, is an Array of VStateData from the vertex dependencies

  • could access @args of the obejct, which was set on object’s constructing

Returns:

  • (Proc)

Raises:



19
20
21
# File 'lib/excadg/payload.rb', line 19

def get
  raise NoPayloadSet, 'payload is empty'
end

#initialize(args: nil) ⇒ Object

constructor to store arguments for the lambda in the object

implementation implies that child class could implement #sanitize to transform args as needed



27
28
29
# File 'lib/excadg/payload.rb', line 27

def initialize args: nil
  @args = respond_to?(:sanitize) ? send(:sanitize, args) : args
end