Class: Rdbc::Contract
- Inherits:
-
Object
- Object
- Rdbc::Contract
- Defined in:
- lib/rdbc/contract.rb
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rdbc/contract.rb', line 25 def method_missing(method, *args) send_if_respond_to(Rdbc::Translator.method_pre(method), @object, *args) before = @object.dup begin result = @object.send(method, *args) rescue RuntimeError => result end send_if_respond_to(:invariant, @object) send_if_respond_to(Rdbc::Translator.method_post(method), before, @object, result, *args) if result.kind_of?(RuntimeError) raise result else result end end |