Sha256: 5a8840fc8d982547e4416cbb75dcdd87c4cdd1e8ac12d8420ecf872e8715b91c

Contents?: true

Size: 890 Bytes

Versions: 24

Compression:

Stored size: 890 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) if SCR.get_arg(arg)
          end
          io.options
        end

      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
eco-helpers-1.1.8 lib/eco/cli/config/options_set.rb
eco-helpers-1.1.7 lib/eco/cli/config/options_set.rb
eco-helpers-1.1.6 lib/eco/cli/config/options_set.rb
eco-helpers-1.1.5 lib/eco/cli/config/options_set.rb
eco-helpers-1.1.4 lib/eco/cli/config/options_set.rb
eco-helpers-1.1.3 lib/eco/cli/config/options_set.rb
eco-helpers-1.1.2 lib/eco/cli/config/options_set.rb
eco-helpers-1.1.1 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.14 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.13 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.12 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.11 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.10 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.9 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.8 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.7 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.6 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.5 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.4 lib/eco/cli/config/options_set.rb
eco-helpers-1.0.3 lib/eco/cli/config/options_set.rb