Module: Atlas::Validations::InstanceMethods

Defined in:
lib/atlas/mixins/validations.rb

Instance Method Summary collapse

Instance Method Details

#validate!Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/atlas/mixins/validations.rb', line 9

def validate!
  missing = self.class.required_attributes[self.class.name].reject do |k|
    to_hash.include?(k) && !to_hash[k].nil?
  end

  if missing.any?
    raise Atlas::Errors::InvalidResourceError,
      "Missing attributes: #{missing.join(', ')}"
  end
end