Class: Handshake::Invariant
- Inherits:
-
Object
- Object
- Handshake::Invariant
- Defined in:
- lib/handshake.rb
Overview
This class defines a class invariant, which has a block and an optional method. Not for external use.
Instance Method Summary collapse
-
#holds?(o) ⇒ Boolean
Any -> Boolean Evaluates this class’s block in the binding of the given object.
-
#initialize(mesg = nil, &block) ⇒ Invariant
constructor
:nodoc:.
- #mesg ⇒ Object
Constructor Details
#initialize(mesg = nil, &block) ⇒ Invariant
:nodoc:
470 471 472 473 |
# File 'lib/handshake.rb', line 470 def initialize(mesg=nil, &block) @mesg = mesg @block = block end |
Instance Method Details
#holds?(o) ⇒ Boolean
Any -> Boolean Evaluates this class’s block in the binding of the given object.
476 477 478 479 |
# File 'lib/handshake.rb', line 476 def holds?(o) block = @block o.instance_eval(&block) end |
#mesg ⇒ Object
480 481 482 |
# File 'lib/handshake.rb', line 480 def mesg @mesg || "Invariant check failed" end |