lib/eco/api/usecases/use_case_io.rb in eco-helpers-1.2.2 vs lib/eco/api/usecases/use_case_io.rb in eco-helpers-1.3.1
- old
+ new
@@ -10,21 +10,28 @@
class UseCaseIO < BaseIO
@types = BaseIO.types
attr_reader :usecase
+ # @param usecase [Eco::API::UseCases::UseCase] the target `usecase`
+ # @param job [Eco::API::Session::Batch::Job] the default `job` of the usecase
# @see Eco::API::UseCases::BaseIO#initialize
- def initialize(usecase:, **kargs)
+ def initialize(usecase:, job: nil, **kargs)
self.usecase = usecase
+ @job = job
super(**kargs)
end
# @see Eco::API::UseCases::BaseIO#new
# @param usecase [Eco::API::UseCases::UseCase] target usecase
# @return [Eco::API::UseCases::UseCaseIO]
def new(usecase:, **kargs)
- super(**kargs.merge(usecase: usecase))
+ default = {
+ usecase: usecase,
+ job: @job
+ }
+ super(**default.merge(kargs))
end
# @param value [Eco::API::UseCases::UseCase] the usecase this InputOuput should be linked to
def usecase=(value)
@@ -44,13 +51,16 @@
# @see Eco::API::UseCases::BaseIO#params
# Same as its superclass but adding `usecase` parameter
def params(keyed: false)
super(keyed: keyed).tap do |res|
if keyed
- res.merge!(usecase: usecase)
+ res.merge!({
+ usecase: usecase,
+ job: @job
+ })
else
- res.push(usecase)
+ res.push(usecase).push(@job)
end
end
end
def chain(usecase:)
@@ -62,10 +72,10 @@
case self.type
when :import
kargs[:input] = output
when :filter
kargs[:people] = output
- when :transform, :sync, :export
+ when :transform, :sync, :export, :error_handler
# no redirections => should it redirect the input?
end
self.class.new(kargs)
end
end