Sha256: 6523ed520227cb9d8e94848929306959dc5ad607527b4bf5c9a623e89343ab2d
Contents?: true
Size: 1.78 KB
Versions: 13
Compression:
Stored size: 1.78 KB
Contents
module Eco module API class UseCases class UseCaseIO < BaseIO @types = [:import, :filter, :transform, :sync, :export] attr_reader :usecase def initialize(usecase:, **kargs) self.usecase = usecase super(**kargs) end # @see Eco::API::UseCases::BaseIO # @param usecase [Eco::API::UseCases::UseCase] target usecase # @return [Eco::API::UseCases::UseCaseIO] def new(usecase:, **kargs) super(**kargs.merge(usecase: usecase)) end 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 def type @usecase.type end def type=(value) raise "Can't modify type depends on the usecase linked to this IO object" end def params(keyed: false) super(keyed: keyed).tap do |res| if keyed res.merge!(usecase: usecase) else res.push(usecase) end 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) case self.type when :import kargs[:input] = output when :filter kargs[:people] = output when :transform, :sync, :export # no redirections => should it redirect the input? end self.class.new(kargs) end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems