Class: Flows::SharedContextPipeline::Wrap Private

Inherits:
Object
  • Object
show all
Defined in:
lib/flows/shared_context_pipeline/wrap.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

Constant Summary collapse

EMPTY_HASH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

{}.freeze
NODE_PREPROCESSOR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

lambda do |_input, context, _node_meta|
  [[context], EMPTY_HASH]
end
NODE_POSTPROCESSOR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

lambda do |result, context, _node_meta|
  context[:data].merge!(result.instance_variable_get(:@data))

  result
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name:, router_def:, &tracks_definitions) ⇒ Wrap

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Wrap.

Since:

  • 0.4.0



22
23
24
25
26
27
28
29
30
31
# File 'lib/flows/shared_context_pipeline/wrap.rb', line 22

def initialize(method_name:, router_def:, &tracks_definitions)
  @method_name = method_name
  @router_def = router_def
  @tracks_definitions = tracks_definitions

  singleton_class.extend DSL::Tracks
  singleton_class.extend Result::Helpers

  singleton_class.instance_exec(&tracks_definitions)
end

Instance Attribute Details

#next_stepObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

:reek:Attribute

Since:

  • 0.4.0



8
9
10
# File 'lib/flows/shared_context_pipeline/wrap.rb', line 8

def next_step
  @next_step
end

#router_defObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



5
6
7
# File 'lib/flows/shared_context_pipeline/wrap.rb', line 5

def router_def
  @router_def
end

#tracks_definitionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



5
6
7
# File 'lib/flows/shared_context_pipeline/wrap.rb', line 5

def tracks_definitions
  @tracks_definitions
end

Instance Method Details

#initialize_dup(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

on #dup we're getting new empty singleton class so we need to initialize it like original one

Since:

  • 0.4.0



35
36
37
38
39
# File 'lib/flows/shared_context_pipeline/wrap.rb', line 35

def initialize_dup(other)
  singleton_class.extend DSL::Tracks
  singleton_class.extend Result::Helpers
  singleton_class.instance_exec(&other.tracks_definitions)
end

#nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



41
42
43
# File 'lib/flows/shared_context_pipeline/wrap.rb', line 41

def name
  singleton_class.tracks.first_step_name
end

#to_node(method_source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



45
46
47
48
49
50
51
52
53
# File 'lib/flows/shared_context_pipeline/wrap.rb', line 45

def to_node(method_source)
  Flows::Flow::Node.new(
    body: make_body(method_source),
    router: router_def.to_router(next_step),
    meta: { wrap_name: @method_name },
    preprocessor: NODE_PREPROCESSOR,
    postprocessor: NODE_POSTPROCESSOR
  )
end