Module: Eco::API::UseCases::BaseIO::Chaining

Included in:
Eco::API::UseCases::BaseIO
Defined in:
lib/eco/api/usecases/base_io/chaining.rb

Instance Method Summary collapse

Instance Method Details

#chained(as: type) ⇒ Eco::API::UseCases::BaseIO

Note:

if there isn't output it doesn't do the switch, provided that it preserves the target parameter (otherise it would blank it)

Does the switch from output to result in a new IO object.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/eco/api/usecases/base_io/chaining.rb', line 22

def chained(as: type) # rubocop:disable Naming/MethodParameterName

  base.tap do |io_base|
    next unless io_base.output

    case as
    when :import
      io_base.output_be_input!
    when :filter
      io_base.output_be_data!
      # when :transform, :sync, :export, :error_handler, :other

    end
  end
end

#process_case(case_name, case_type, **params) ⇒ Eco::API::UseCases::BaseIO

Note:
  1. It swaps output to input or data depending on self.type
  2. does this, before the target case_name launch and **after

Shortcut to run a usecase passing this io as parameter



8
9
10
11
12
13
14
15
# File 'lib/eco/api/usecases/base_io/chaining.rb', line 8

def process_case(case_name, case_type, **params)
  session.process_case(
    case_name,
    io:   chained,
    type: case_type,
    **params
  ).chained
end