Aop?

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

On Feb 3, 10:55 pm, [email protected] wrote:

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.

[email protected] schrieb:

Is there an AOP implementation for Ruby?
Have a look at http://rubyforge.org/projects/aspectr/

Regards,
Jan

Trans wrote:

On Feb 3, 10:55 pm, [email protected] wrote:

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs