Module: Handshake::InstanceMethods

Defined in:
lib/handshake/handshake.rb

Instance Method Summary collapse

Instance Method Details

#check_invariants!Object

Checks the invariants defined on this class against self, raising a ContractViolation if any of them fail.



349
350
351
352
353
354
355
356
# File 'lib/handshake/handshake.rb', line 349

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