Module: EdtfRails::Util::ClassMethods

Defined in:
lib/edtf-rails/util.rb

Instance Method Summary collapse

Instance Method Details

#check_edtf_options(options, admitted_keys) ⇒ Object

Raises:

  • (WrongArgumentException)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/edtf-rails/util.rb', line 9

def check_edtf_options(options, admitted_keys)

  raise WrongArgumentException, "first argument must be in a hash." unless options.is_a? Hash
  raise WrongArgumentException, "seconf argument must be in an array." unless admitted_keys.is_a? Array

  options.each do |key, value|
    unless admitted_keys.include? key
      raise WrongOptionException.new("Unknown option: #{key.inspect} => #{value.inspect}.")
    end
    if block_given?
      yield key, value
    end
  end

end