[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

mrunalp

2/4/2007 3:55:00 AM

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

3 Answers

Trans

2/4/2007 4:26:00 AM

0



On Feb 3, 10:55 pm, mrun...@gmail.com 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....
http://facets.rub... (see cut.rb)
http://aspectr.source...
http://debasishg.blogspot.com/2006/06/does-ruby-nee...

T.


Karmic Mishap

2/4/2007 7:00:00 PM

0

Trans wrote:
> On Feb 3, 10:55 pm, mrun...@gmail.com 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.ruby...). 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

Jan Friedrich

2/5/2007 7:49:00 AM

0

mrunalp@gmail.com schrieb:
> Is there an AOP implementation for Ruby?
Have a look at http://rubyforge.org/project...

Regards,
Jan