Exception: Safer::Protocol::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Safer::Protocol::Error
- Defined in:
- lib/safer/protocol.rb
Overview
Error generated when a class does not conform to a protocol signature.
Direct Known Subclasses
Defined Under Namespace
Classes: ClassError, InstanceError
Instance Method Summary collapse
-
#==(other_object) ⇒ Object
Compare two Safer::Protocol::Error objects for content equality.
-
#initialize(message, error_object, protocol, class_violations, instance_violations) ⇒ Error
constructor
Create a Safer::Protocol::Error object.
-
#self ⇒ Object
:attr_reader: report String for displaying human-readable error message describing protocol violations.
Constructor Details
#initialize(message, error_object, protocol, class_violations, instance_violations) ⇒ Error
Create a Safer::Protocol::Error object. Used internally.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/safer/protocol.rb', line 271 def initialize(, error_object, protocol, class_violations, instance_violations) super() self.safer_protocol_error__error_object = error_object self.safer_protocol_error__protocol = protocol self.safer_protocol_error__class_violations = class_violations self.safer_protocol_error__instance_violations = instance_violations report = '' if class_violations report += "Class method errors:\n" + self.safer_protocol_error__class_violations.report if instance_violations report += "\n\n" end end if instance_violations report += "Instance method errors:\n" + self.safer_protocol_error__instance_violations.report end self.safer_protocol_error__report = report end |
Instance Method Details
#==(other_object) ⇒ Object
Compare two Safer::Protocol::Error objects for content equality.
296 297 298 299 300 301 302 |
# File 'lib/safer/protocol.rb', line 296 def ==(other_object) self.class == other_object.class && self.error_object == other_object.error_object && self.protocol == other_object.protocol && self.class_violations == other_object.class_violations && self.instance_violations == other_object.instance_violations end |