Sha256: 5d84dc6bc32b1f69e03e4c463b84317c85e055a56a3c17fc89cb3184694c2ed9

Contents?: true

Size: 902 Bytes

Versions: 26

Compression:

Stored size: 902 Bytes

Contents

module Eco
  class CLI
    class Config
      class OptionsSet
        attr_reader :core_config

        def initialize(core_config:)
          @core_config = core_config
          @options_set = {}
        end

        def add(option)
          raise "Missing block to define the options builder" unless block_given?
          callback = Proc.new
          [option].flatten.compact.each do |opt|
            @options_set[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

          @options_set.each do |arg, callback|
            callback.call(io.options, io.session) if SCR.get_arg(arg)
          end
          io.options
        end

      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
eco-helpers-1.5.1 lib/eco/cli/config/options_set.rb
eco-helpers-1.5.0 lib/eco/cli/config/options_set.rb
eco-helpers-1.4.2 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.19 lib/eco/cli/config/options_set.rb
eco-helpers-1.4.1 lib/eco/cli/config/options_set.rb
eco-helpers-1.4.0 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.18 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.17 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.16 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.15 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.14 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.13 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.12 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.11 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.10 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.9 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.8 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.7 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.6 lib/eco/cli/config/options_set.rb
eco-helpers-1.3.5 lib/eco/cli/config/options_set.rb