Method: Fog::Attributes::InstanceMethods#requires

Defined in:
lib/fog/core/attributes.rb

#requires(*args) ⇒ Object

check that the attributes specified in args exist and is not nil

[View source]

160
161
162
163
164
165
166
167
# File 'lib/fog/core/attributes.rb', line 160

def requires(*args)
  missing = missing_attributes(args)
  if missing.length == 1
    raise(ArgumentError, "#{missing.first} is required for this operation")
  elsif missing.any?
    raise(ArgumentError, "#{missing[0...-1].join(", ")} and #{missing[-1]} are required for this operation")
  end
end