Module: GDataPlus::Util

Defined in:
lib/gdata_plus/util.rb

Class Method Summary collapse

Class Method Details

.prepare_options(options, required_keys, optional_keys = []) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/gdata_plus/util.rb', line 7

def prepare_options(options, required_keys, optional_keys = [])
  options = options.symbolize_keys
  options.assert_valid_keys(required_keys + optional_keys)
  required_keys.each do |key|
    raise ArgumentError, "#{key.inspect} option required" if options[key].nil?
  end
  options
end

.raise_if_error(response) ⇒ Object



16
17
18
19
20
# File 'lib/gdata_plus/util.rb', line 16

def raise_if_error(response)
  unless (200..299).include? response.code
    raise Exception.new(response)
  end
end