Class: Avm::SourceGenerators::OptionList

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/source_generators/option_list.rb

Instance Method Summary collapse

Instance Method Details

#immutable_optionObject



12
# File 'lib/avm/source_generators/option_list.rb', line 12

alias immutable_option option

#option(*args) ⇒ Object



14
15
16
# File 'lib/avm/source_generators/option_list.rb', line 14

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

#validate(options_hash) ⇒ Hash<Symbol, String>

Returns:

  • (Hash<Symbol, String>)


19
20
21
# File 'lib/avm/source_generators/option_list.rb', line 19

def validate(options_hash)
  options_hash.transform_keys { |k| validate_option(k) }
end

#validate_option(option_name) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/avm/source_generators/option_list.rb', line 23

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