Forum: Ruby AOP in Ruby ...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
markcollinscope (Guest)
on 2005-11-28 15:48
(Received via mailing list)
Hi  there,

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

Ciao,
Mark.
bob.news (Guest)
on 2005-11-28 15:56
(Received via mailing list)
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
christian.leskowsky (Guest)
on 2005-11-28 17:34
(Received via mailing list)
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.
removed_email_address@domain.invalid
ed.howland (Guest)
on 2005-11-28 18:47
(Received via mailing list)
On 11/28/05, Mark Collins-Cope <removed_email_address@domain.invalid> 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%22

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
Daniel.Berger (Guest)
on 2005-11-28 18:55
(Received via mailing list)
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/...

Regards,

Dan
christian.leskowsky (Guest)
on 2005-11-28 19:27
(Received via mailing list)
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
ed.howland (Guest)
on 2005-11-28 20:52
(Received via mailing list)
On 11/28/05, Daniel B. <removed_email_address@domain.invalid> wrote:
> Ed Howland wrote:
>
> I think I prefer the Sydney approach to AOP, which uses Behaviors:
>
> http://hoshi.fallingsnow.net/svn/sydney/trunk/lib/...
>
> Regards,

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

Ed
m-lists (Guest)
on 2005-11-29 00:02
(Received via mailing list)
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
Jim W. (Guest)
on 2005-11-29 05:19
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.
transfire (Guest)
on 2005-11-29 07:10
(Received via mailing list)
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.
george.moschovitis (Guest)
on 2005-11-29 10:28
(Received via mailing list)
On 11/28/05, Mark Collins-Cope <removed_email_address@domain.invalid> 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.
This topic is locked and can not be replied to.