Module: OCG::Validation

Defined in:
lib/ocg/validation.rb

Overview

OCG::Validation module.

Class Method Summary collapse

Class Method Details

.validate_options(options) ⇒ Object

Raises error when options is not hash

and option values are not convertable to array
and option values are not empty.

Raises:



12
13
14
15
16
17
18
19
# File 'lib/ocg/validation.rb', line 12

def self.validate_options(options)
  raise ValidateError, "invalid options hash" unless options.is_a? ::Hash

  options.each do |_name, values|
    raise ValidateError, "option values should respond to \"to_a\"" unless values.respond_to? :to_a
    raise ValidateError, "option values should not be empty" if values.to_a.empty?
  end
end