AOP?

M

mrunalp

Hi,
Is there an AOP implementation for Ruby?
I have heard that using metaprogramming facilities obviates AOP.
How is it so?
Thanks
 
T

Trans

Hi,
Is there an AOP implementation for Ruby?
I have heard that using metaprogramming facilities obviates AOP.
How is it so?
Thanks

I will give you a very broad example and you can narrow it from there:

ObjectSpace.each_object(Class) do |c|
c.class_eval do
c.instance_methods(false).each do |m|
alias_method "_#{m}", m
define_method(m) do |*args|
puts "doing #{m}..."
send("_#{m}",*args)
end
end
end
end

Note this is untested, and imperfect, but it should give you a good
idea of how Ruby's metaprogramming abilities can be used for AOP.

Some other things that might interest you:

http://rcrchive.net/rcrs/1
http://facets.rubyforge.org (see cut.rb)
http://aspectr.sourceforge.net/
http://debasishg.blogspot.com/2006/06/does-ruby-need-aop.html

T.
 
R

Ronnie

For those of us who are lazy or interested in IOC features, there is
Copland (http://copland.rubyforge.org/). It provides support for
AOP-like pre- and post- hooks, as well as providing a wealth of other
features, such as dependency injection, service factories, and
registries which help keep modules of large systems decoupled from each
other. I'm still learning about it myself, but it may help you out if
you want any of those features in addition to basic AOP.

Hope that helps,
Ronnie Garduño
 

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

Ruby and AOP 6
ruby and aop 9
AOP and Ruby 4
AOP in Ruby ... 8
Perspectives for Ruby 2.0 8
refactor.rb (decoration plus AOP) 1
how to model AOP using UML? 2
Aspect Oriented Programming 1

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top