Sha256: dfcb3f5739a18a440eec5da6f35eea1b731ba8dff46a7630a02ba1818c5651b0
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
module Rdbc class Contract class << self include Translating def pre(method, &block) define_method(method_pre(method), &block) end def post(method, &block) define_method(method_post(method), &block) end def invariant(&block) define_method(:invariant, &block) end end include Translating class AssertionFailed < RuntimeError end def assert(condition) raise AssertionFailed unless condition end def send_method_pre(method, object, *args) method_pre = method_pre(method) if respond_to?(method_pre) send(method_pre, object, *args) end end def send_invariant(object) if respond_to?(:invariant) invariant(object) end end def send_method_post(method, object_pre, object, exception, result, *args) method_post = method_post(method) if respond_to?(method_post) send(method_post, object_pre, object, exception, result, *args) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
armin-joellenbeck-rdbc-0.2.3 | lib/rdbc/contract.rb |
armin-joellenbeck-rdbc-0.2.4 | lib/rdbc/contract.rb |
armin-joellenbeck-rdbc-0.2.5 | lib/rdbc/contract.rb |