Module: Handshake::InstanceMethods
- Defined in:
- lib/handshake.rb
Instance Method Summary collapse
-
#check_invariants! ⇒ Object
Checks the invariants defined on this class against
self
, raising a ContractViolation if any of them fail.
Instance Method Details
#check_invariants! ⇒ Object
Checks the invariants defined on this class against self
, raising a ContractViolation if any of them fail.
314 315 316 317 318 319 320 321 |
# File 'lib/handshake.rb', line 314 def check_invariants! self.class.invariants.each do |invar| unless invar.holds?(self) mesg = invar.mesg || "Invariant check failed" throw :contract, ContractViolation.new(mesg) end end end |