def destruction_allowed?
      success = protect_if_methods.all? do |method, message|
        allowed = protect_method_allows_destruction(method)
        errors.add(:base, message) if !allowed && message
        allowed
      end

      throw(:abort) if !success && ActiveRecord::VERSION::MAJOR >= 5
      success
    end
def destruction_allowed?
      success = protect_if_methods.all? do |method, message|
        allowed = protect_method_allows_destruction(method)
        errors.add(:base, message) if !allowed && message
        allowed
      end

      throw(:abort) if !success && ActiveRecord::VERSION::MAJOR >= 5
      success
    end
Returns true if this record may be destroyed or
 adds possible error messages to the #errors object otherwise.