Meta-Meta-Programming, revisited

E

Erik Veenstra

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

----------------------------------------------------------------
 
E

Erik Veenstra

What about |obj, method_name, args, block|? That one must
Changed. [1]
Hey, wrap_method doesn't receive *method_names... yet... ;]

Fixed. [2]

I changed the internals of wrap_module slightly, but enough to
be measurably faster... [2]

The implementation of "once" is now thread safe. [3]

gegroet,
Erik V. - http://www.erikveen.dds.nl/

[1] http://www.erikveen.dds.nl/monitorfunctions/index.html#4.0.0
[2] http://www.erikveen.dds.nl/monitorfunctions/index.html#5.2.0
[3] http://www.erikveen.dds.nl/monitorfunctions/index.html#6.3.0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Meta-Meta-Programming 29
Beginning meta-programming question 1
#meta 15
Java programming 1
Automatic setup of meta path hooks? 0
Help with simple meta programming 1
meta reflection in c++ 0
meta pre-processor 23

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top