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
avm-0.94.1 lib/avm/source_generators/option_list.rb
eac_tools-0.98.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.94.0 lib/avm/source_generators/option_list.rb
eac_tools-0.94.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.93.0 lib/avm/source_generators/option_list.rb
eac_tools-0.92.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.92.0 lib/avm/source_generators/option_list.rb
eac_tools-0.91.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.90.1 lib/avm/source_generators/option_list.rb
eac_tools-0.87.1 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.90.0 lib/avm/source_generators/option_list.rb
eac_tools-0.87.0 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.89.0 lib/avm/source_generators/option_list.rb
eac_tools-0.86.12 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.88.0 lib/avm/source_generators/option_list.rb
eac_tools-0.86.11 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.87.0 lib/avm/source_generators/option_list.rb
eac_tools-0.86.8 sub/avm/lib/avm/source_generators/option_list.rb
avm-0.86.2 lib/avm/source_generators/option_list.rb
eac_tools-0.86.7 sub/avm/lib/avm/source_generators/option_list.rb