AOP in Ruby

Hi there,

I was wondering if there is any support (in the form of frameworks or
whatever) for AOP in Ruby?

Ciao,
Mark.

Mark Collins-Cope wrote:

Hi there,

I was wondering if there is any support (in the form of frameworks or
whatever) for AOP in Ruby?

There seems to be some:
http://raa.ruby-lang.org/search.rhtml?search=aop

robert

I thought aspects were baked into the language. You just have to
re-open a
definition like:

class A
def a_method
# do something
end
end

class B < A
alias old_a_method a_method

def a_method
puts “I’m an aspect”

old_a_method

end
end

Maybe I’m climbing up the wrong tree. Dependency injection and AOP are
different problems aren’t they?

‘There was an owl lived in an oak.
The more he heard, the less he spoke.
The less he spoke, the more he heard.’

Christian L.
[email protected]

Ed Howland wrote:

I’ve tried this out and it seems to work fairly well in my limited

Mark.
I think I prefer the Sydney approach to AOP, which uses Behaviors:

http://hoshi.fallingsnow.net/svn/sydney/trunk/lib/behavior/aop.rb

Regards,

Dan

I like the Sydney stuff a little more too… Seems cleaner somehow.

The RCR sounded neat up until I got to: “A way to specify alternate
method-to-advice mappings” where it started to break down for me. An
interesting read though.

Chris

On 11/28/05, Daniel B. [email protected] wrote:

Ed Howland wrote:

I think I prefer the Sydney approach to AOP, which uses Behaviors:

http://hoshi.fallingsnow.net/svn/sydney/trunk/lib/behavior/aop.rb

Regards,

Is there any documentation on this? The upper level README is just a
file manifest.

Ed

On 11/28/05, Mark Collins-Cope [email protected] wrote:

Hi there,

I was wondering if there is any support (in the form of frameworks or
whatever) for AOP in Ruby?

There is Cut, as defined in RCR 321
http://www.rcrchive.net/rcr/show/321"

I’ve tried this out and it seems to work fairly well in my limited
exposure. Cuts are
transparent subclasses. While the technique in Christian’a reply
works, Cut is more broad based. You can reuse aspects by enclosing
them in modules, and apply the Cut class across ObjectSpace to have
system-wide aspects.

Ed

m-lists wrote:

Christian L. wrote:

I thought aspects were baked into the language. You just have to
re-open a
definition like:
[… example elided …]

That’s not exactly the same thing as AOP is it (or a very special case)?
I mean, with AOP you should be able to define things like pointcuts to
apply advice to etc. What you described feels very much like a around
advice applied to a single method.

It is, but creating a general solution out of that is not a difficult
exercise. That’s the point, AOP lies very close to the surface of Ruby
code.

– Jim W.

Christian L. wrote:

I like the Sydney stuff a little more too… Seems cleaner somehow.

The RCR sounded neat up until I got to: “A way to specify alternate
method-to-advice mappings” where it started to break down for me.

So one advice can be used for many methods. Sorry if I made it sound
more complicated than it is.

T.

Christian L. wrote:

I thought aspects were baked into the language. You just have to
re-open a
definition like:

class A
def a_method
# do something
end
end

class B < A
alias old_a_method a_method

def a_method
puts “I’m an aspect”

old_a_method

end
end

Maybe I’m climbing up the wrong tree. Dependency injection and AOP
are
different problems aren’t they?

That’s not exactly the same thing as AOP is it (or a very special case)?
I mean, with AOP you should be able to define things like pointcuts to
apply advice to etc. What you described feels very much like a around
advice applied to a single method. If you would do that to all methods
you would like to advice with for example transactionality you would be
in for a lot of typing in contrast to doing it with pointcuts based on
regexp applied to class/method names.

/Marcus

On 11/28/05, Mark Collins-Cope [email protected] wrote:

Hi there,

I was wondering if there is any support (in the form of frameworks or
whatever) for AOP in Ruby?

Nitro + Og support AOP, have a look at http://www.nitrohq.com

-g.