module Eco class CLI class Config class PeopleFilters attr_reader :core_config def initialize(core_config:) @core_config = core_config @filters = {} end def add(option) raise "Missing block to define the filters builder" unless block_given? callback = Proc.new [option].flatten.compact.each do |opt| @filters[opt] = callback end self end def process(io:) unless io && io.is_a?(Eco::API::UseCases::BaseIO) raise "You need to provide Eco::API::UseCases::BaseIO object. Given: #{io.class}" end io = io.new(type: :transform) @filters.each do |arg, callback| if SCR.get_arg(arg) io = io.new(people: callback.call(*io.params)) end end io.people end end end end end