Class: Proc
- Inherits:
-
Object
- Object
- Proc
- Defined in:
- lib/handshake/block_contract.rb
Instance Attribute Summary collapse
-
#contract ⇒ Object
Returns the value of attribute contract.
Instance Method Summary collapse
- #checked? ⇒ Boolean
- #checked_call(*args) ⇒ Object (also: #call)
Instance Attribute Details
#contract ⇒ Object
Returns the value of attribute contract.
2 3 4 |
# File 'lib/handshake/block_contract.rb', line 2 def contract @contract end |
Instance Method Details
#checked? ⇒ Boolean
11 12 13 |
# File 'lib/handshake/block_contract.rb', line 11 def checked? not @contract.nil? end |
#checked_call(*args) ⇒ Object Also known as: call
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/handshake/block_contract.rb', line 15 def checked_call(*args) Handshake.catch_contract("Contract violated in call to proc #{self}") do @contract.check_accepts! *args end if checked? return_value = orig_call(*args) Handshake.catch_contract("Contract violated by proc #{self}") do @contract.check_returns! return_value end if checked? return_value end |