lib/eco/api/usecases/use_case_io.rb in eco-helpers-1.5.1 vs lib/eco/api/usecases/use_case_io.rb in eco-helpers-1.5.2

- old
+ new

@@ -28,11 +28,10 @@ default = { usecase: usecase } default.merge!(job: @job) if @job super(**default.merge(kargs)) end - # @param value [Eco::API::UseCases::UseCase] the usecase this InputOuput should be linked to def usecase=(value) raise "It should be a Eco::API::UseCases::UseCase. Given: #{value}" if !value.is_a?(Eco::API::UseCases::UseCase) @usecase = value end @@ -45,13 +44,13 @@ def type=(value) raise "Can't modify type depends on the usecase linked to this IO object" end # @see Eco::API::UseCases::BaseIO#params - # Same as its superclass but adding `usecase` parameter - def params(keyed: false) - super(keyed: keyed).tap do |res| + # Same as its superclass but adding `usecase` and `job` parameters + def params(keyed: false, all: false) + super(keyed: keyed, all: all).tap do |res| if keyed res.merge!(usecase: usecase) res.merge!(job: @job) if @job else res.push(usecase) @@ -60,22 +59,23 @@ end end def chain(usecase:) raise "It should be a UseCase. Given: #{usecase}" if !usecase.is_a?(UseCase) + #aux_io = self.class.new(input: input, people: people, session: session, options: options, usecase: usecase) + #kargs = aux_io.params(keyed: true) + kargs = params(keyed: true, all: true).merge(usecase: usecase) + kargs.delete(:job) - aux_io = self.class.new(input: input, people: people, session: session, options: options, usecase: usecase) - kargs = aux_io.params(keyed: true) - case self.type when :import kargs[:input] = output when :filter kargs[:people] = output - when :transform, :sync, :export, :error_handler + when :transform, :sync, :export, :error_handler, :other # no redirections => should it redirect the input? end - self.class.new(kargs) + self.class.new(**kargs) end end end end