Module: Handshake::InstanceMethods

Defined in:
lib/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.



295
296
297
298
299
300
301
302
# File 'lib/handshake.rb', line 295

def check_invariants!
  self.class.invariants.each do |invar|
    unless invar.holds?(self)
      mesg = invar.mesg || "Invariant check failed"
      throw :contract, ContractViolation.new(self.class.to_s + " " + mesg)
    end
  end
end