Not sure how the method_name parameter is useful, isn't it
just :description? In any case, the paraemters are nicely
intuitive!
post_condition (like pre_condition) receives *method_names. So,
passing the name of the wrapped method might be usefull.
Hey, wrap_method doesn't receive *method_names... yet... ;]
gegroet,
Erik V. - http://www.erikveen.dds.nl/
···
----------------------------------------------------------------
class Module
def wrap_method(method_name, &block1)
>
wrappping_block.call(old, args2, block2, self)
>
end
def pre_condition(*method_names, &block1)
method_names.flatten.each do |method_name|
wrap_method(method_name) do |org_method, args2, block2, obj2|
block1.call(obj2, method_name, args2, block2)
org_method.call(*args2, &block2) if org_method
end
end
end
def post_condition(*method_names, &block1)
method_names.flatten.each do |method_name|
wrap_method(method_name) do |org_method, args2, block2, obj2|
org_method.call(*args2, &block2) if org_method
block1.call(obj2, method_name, args2, block2)
end
end
end
end
----------------------------------------------------------------