Method: Utilities#required_option

Defined in:
lib/utilities.rb

#required_option(options, key) ⇒ Object

Throws an error if an option is missing

great for checking if properties exist

Attributes

  • options - the options hash

  • key - key to find

Raises:

  • (ArgumentError)


149
150
151
152
153
# File 'lib/utilities.rb', line 149

def required_option(options, key)
  result = get_option(options, key)
  raise ArgumentError, "Missing required option: #{key}" if result == ""
  result
end