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

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 RCR 321: Aspect Oriented Programming for Ruby

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

···

On 11/28/05, Mark Collins-Cope <markcollinscope@gmail.com> wrote:

Ciao,
Mark.

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

-g.

···

On 11/28/05, Mark Collins-Cope <markcollinscope@gmail.com> wrote:

Hi there,

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

--
http://www.gmosx.com
http://www.navel.gr

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 Leskowsky
christian.leskowsky@gmail.com

On 11/28/05, Robert Klemme <bob.news@gmx.net> wrote:

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

Ed Howland wrote:

···

On 11/28/05, Mark Collins-Cope <markcollinscope@gmail.com> 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 RCR 321: Aspect Oriented Programming for Ruby

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

Ciao,
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 Berger <Daniel.Berger@qwest.com> wrote:

Ed Howland wrote:
> On 11/28/05, Mark Collins-Cope <markcollinscope@gmail.com> 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
RCR 321: Aspect Oriented Programming for Ruby
>
> 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
>
>
>>Ciao,
>>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

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

Ed

···

On 11/28/05, Daniel Berger <Daniel.Berger@qwest.com> 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,

Christian Leskowsky 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

m-lists wrote:

Christian Leskowsky 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 Weirich

···

--
Posted via http://www.ruby-forum.com/\.

Christian Leskowsky 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.