def errors
      self.class.relationships.inject(super) do |acc, data|
        name, options = data

        if options && options[:klass].respond_to?(:errors_for_relationship)
          errors = options[:klass].errors_for_relationship(self, relationship_data[name])
          acc.merge!(name => errors) if errors && !errors.empty?
        end

        acc
      end
    end
def errors
      self.class.relationships.inject(super) do |acc, data|
        name, options = data

        if options && options[:klass].respond_to?(:errors_for_relationship)
          errors = options[:klass].errors_for_relationship(self, relationship_data[name])
          acc.merge!(name => errors) if errors && !errors.empty?
        end

        acc
      end
    end
Returns the errors for a model.