Sha256: 52a02f407971466fe13d0ada1be6bac9b2754510f94efee2fa92febcbffe64ec

Contents?: true

Size: 775 Bytes

Versions: 195

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

require 'avm/source_generators/option'
require 'eac_ruby_utils/core_ext'

module Avm
  module SourceGenerators
    class OptionList
      enable_immutable
      immutable_accessor :option, type: :array

      alias immutable_option option

      def option(*args)
        immutable_option(::Avm::SourceGenerators::Option.new(*args))
      end

      # @return [Hash<Symbol, String>]
      def validate(options_hash)
        options_hash.transform_keys { |k| validate_option(k) }
      end

      def validate_option(option_name)
        option_name = option_name.to_sym

        return option_name if options.any? { |option| option.name == option_name }

        raise "No option found with name \"#{option_name}\""
      end
    end
  end
end

Version data entries

195 entries across 195 versions & 2 rubygems

Version Path
eac_tools-0.80.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.81.0 lib/avm/source_generators/option_list.rb
eac_tools-0.79.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.80.0 lib/avm/source_generators/option_list.rb
eac_tools-0.78.0 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.77.1 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.77.0 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.76.1 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.76.0 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.75.2 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.75.1 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.75.0 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.74.1 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.74.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.79.0 lib/avm/source_generators/option_list.rb
eac_tools-0.73.0 sub/avm/lib/avm/source_generators/option_list.rb
eac_tools-0.72.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.78.0 lib/avm/source_generators/option_list.rb
eac_tools-0.70.1 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.77.0 lib/avm/source_generators/option_list.rb