AOP in Ruby ...

M

Mark Collins-Cope

Hi there,

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

Ciao,
Mark.
 
E

Ed Howland

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
 
D

Daniel Berger

Ed said:
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

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
 
M

marcus

Christian said:
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
 
J

Jim Weirich

[... 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 Weirich
 
T

Trans

Christian said:
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.
 

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

AOP? 3
ruby and aop 9
Ruby and AOP 6
AOP and Ruby 4
AOP in Python 1
The likes of AOP (1 of 2) 1
aop in ruby 2
[ANN] [RCR] Cut-based AOP 77

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top