Method: VirtualBox::AbstractModel#validate

Defined in:
lib/virtualbox/abstract_model.rb

#validate(*args) ⇒ Object

Validates the model and relationships.



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/virtualbox/abstract_model.rb', line 92

def validate(*args)
  # First clear all previous errors
  clear_errors

  # Then do the validations
  failed = false
  self.class.relationships.each do |name, options|
    next unless options && options[:klass].respond_to?(:validate_relationship)
    failed = true if !options[:klass].validate_relationship(self, relationship_data[name], *args)
  end

  return !failed
end