All
As prompted by the actsAsDecorator() [1] thread I thought I''d post up
the library that I worked on for AOP. It''s based on a lib from
dotvoid.com [2] that I had to hack to get it going cross browser (tested
IE6 + FF 1.5.0.6). The original script crashed IE but I am grateful for
the original work regardless.
The attached zip includes jsunit test so you can fire up the
testRunner.html and run AspectsTest.html to get and idea of usage. The
Aspects lib itself is only dependent on prototype.js
Any feedback etc welcome.
If it''s deemed to be useful I am happy to tidy this stuff up for
inclusion in scriptaculous.
I see AspectsTest.html as _the_ doc for this lib but to give you a
quick
idea of usage :
/*
* Add a around advice to an object INSTANCE.]
*
* //An Example advice :
* function myAroundAdvice() {
* alert(''doing something before method execution'');
* this.proceed();
* alert(''doing something before method execution'');
* }
*
* //Example usage :
* Aspects.addAround(myAroundAdvice, testClass, /test/);
*
* Where testClass is an instance of some object and we want to apply
* the advice to all methods from testClass
* whose name matches the regex /test/
*/
Best
Matt Spendlove
[1]
[2]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
Thanks, Matt. I downloaded the zip with plans to integrate your work into my current project when time permits. I didn''t look at the zip yet, but I''m assuming from your words that the license for this permits that, correct? On 8/30/06, Matt Spendlove <mspendlove506-YDxpq3io04c@public.gmane.org> wrote:> > All > > As prompted by the actsAsDecorator() [1] thread I thought I''d post up > the library that I worked on for AOP. It''s based on a lib from > dotvoid.com [2] that I had to hack to get it going cross browser (tested > IE6 + FF 1.5.0.6). The original script crashed IE but I am grateful for > the original work regardless. > > The attached zip includes jsunit test so you can fire up the > testRunner.html and run AspectsTest.html to get and idea of usage. The > Aspects lib itself is only dependent on prototype.js > > Any feedback etc welcome. > > If it''s deemed to be useful I am happy to tidy this stuff up for > inclusion in scriptaculous. > > I see AspectsTest.html as _the_ doc for this lib but to give you a quick > idea of usage : > > /* > * Add a around advice to an object INSTANCE.] > * > * //An Example advice : > * function myAroundAdvice() { > * alert(''doing something before method execution''); > * this.proceed(); > * alert(''doing something before method execution''); > * } > * > * //Example usage : > * Aspects.addAround(myAroundAdvice, testClass, /test/); > * > * Where testClass is an instance of some object and we want to apply > * the advice to all methods from testClass > * whose name matches the regex /test/ > */ > > Best > > Matt Spendlove > > [1] > > <http://groups.google.com/group/rubyonrails-spinoffs/browse_frm/thread/b63463c5e12ba29b/ffe6ce78bfef6d7c#ffe6ce78bfef6d7c><http://groups.google.com/group/rubyonrails-spinoffs/browse_frm/thread/b63463c5e12ba29b/ffe6ce78bfef6d7c#ffe6ce78bfef6d7c> > > [2] <http://www.dotvoid.com/view.php?id=43><http://www.dotvoid.com/view.php?id=43> > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
I get the concept of ''before'' and ''after'', and I think I understand ''around''. (It''s where you give it a function that does something, then yields to the original function, and when that returns, you run a little bit more code of your own.) The one thing I''m not sure about is ''introduction''. What does it mean to add an introduction? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<font face="Arial,sans-serif"><font
size="2">Yea, use as you wish. Be
good to get an official version sorted if it''s useful but happy for it
to be integrated regardless..<br>
<br>
I am using it here, mainly for unobtrusive logging but also for some
observed / observer style behaviour. For the logger I introduce a class
that configures itself dependent upon browser and applies an Around
Advice to do method entry / exit stamping for debugging. If it''s
Firefox + Firebug it uses the console, else it just writes to a simple
div. <br>
<br>
Be good to see the code getting a going over in other contexts though
to really test it out..<br>
<br>
Matt<br>
<br>
<span type="cite">Ryan Gahl wrote:</span>
</font></font>
<p><font face="Arial,sans-serif"
size="2"></font></p>
<blockquote type="cite" style="border-left: thin solid blue;
padding-left: 10px; margin-left: 0pt;"><font
face="Arial,sans-serif" size="2">Thanks, Matt. I
downloaded the zip
with plans to integrate your work into my current project when time
permits. I didn''t look at the zip yet, but I''m assuming from
your words
that the license for this permits that, correct?
<br>
<br>
</font>
<div><font face="Arial,sans-serif"
size="2"><span class="gmail_quote">On
8/30/06, <b class="gmail_sendername">Matt Spendlove</b>
<<a
href="mailto:mspendlove506-YDxpq3io04c@public.gmane.org">mspendlove506-YDxpq3io04c@public.gmane.org</a>>
wrote:</span></font>
<blockquote class="gmail_quote" style="border-left: 1px
solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;"><font face="Arial,sans-serif"
size="2"></font>
<div><font face="Arial,sans-serif" size="2">
</font>
<div><font face="Arial,sans-serif"
size="2"></font><font face="Courier
New,sans-serif" size="2">All<br>
<br>
As prompted by the actsAsDecorator() [1] thread I thought I''d post
up<br>
the library that I worked on for AOP. It''s based on a lib
from<br>
<a href="http://dotvoid.com" target="_blank"
onclick="return
top.js.OpenExtLink(window,event,this)">dotvoid.com</a>
[2] that I had to hack to get it going cross browser (tested<br>
IE6 + FF <a href="http://1.5.0.6" target="_blank"
onclick="return
top.js.OpenExtLink(window,event,this)">1.5.0.6</a>).
The original script crashed IE but I am grateful for<br>
the original work regardless.<br>
<br>
The attached zip includes jsunit test so you can fire up the<br>
testRunner.html and run AspectsTest.html to get and idea of usage. The<br>
Aspects lib itself is only dependent on prototype.js<br>
<br>
Any feedback etc welcome.<br>
<br>
If it''s deemed to be useful I am happy to tidy this stuff up
for<br>
inclusion in scriptaculous.<br>
<br>
I see AspectsTest.html as _the_ doc for this lib but to give you a
quick <br>
idea of usage :<br>
<br>
/*<br>
* Add a around advice to an object INSTANCE.]<br>
*<br>
* //An Example advice :<br>
* function myAroundAdvice() {<br>
* alert(''doing something before method execution'');<br>
* this.proceed();<br>
* alert(''doing something before method execution'');<br>
* }<br>
*<br>
* //Example usage :<br>
* Aspects.addAround(myAroundAdvice, testClass, /test/);<br>
*<br>
* Where testClass is an instance of some object and we want to apply<br>
* the advice to all methods from testClass<br>
* whose name matches the regex /test/<br>
*/<br>
<br>
Best<br>
<br>
Matt Spendlove<br>
<br>
[1] <br>
<a
href="http://groups.google.com/group/rubyonrails-spinoffs/browse_frm/thread/b63463c5e12ba29b/ffe6ce78bfef6d7c#ffe6ce78bfef6d7c"
target="_blank" onclick="return
top.js.OpenExtLink(window,event,this)"><http://groups.google.com/group/rubyonrails-spinoffs/browse_frm/thread/b63463c5e12ba29b/ffe6ce78bfef6d7c#ffe6ce78bfef6d7c>
</a>
<br>
<br>
[2] <a href="http://www.dotvoid.com/view.php?id=43"
target="_blank" onclick="return
top.js.OpenExtLink(window,event,this)"><http://www.dotvoid.com/view.php?id=43></a><br>
<br>
<span type="cite" style="white-space:
nowrap;">
<br>
<br>
</span></font></div>
</div>
<font face="Arial,sans-serif" size="2"><br>
<br>
<br>
<br clear="all">
</font></blockquote>
</div>
<font face="Arial,sans-serif" size="2"><br>
<br>
<br>
</font></blockquote>
<br>
--~--~---------~--~----~------------~-------~--~----~<br>
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group. <br> To post to this
group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To
unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
<br> For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs <br>
-~----------~----~----~----~------~----~------~--~---<br>
</body>
</html>
<br>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <font face="Arial,sans-serif"><font size="2">The introduction is just a way to mixin one Objects methods into another E.g.I mixin logger methods into my Objects to allows this.debug() etc..<br> <br> <a class="moz-txt-link-rfc2396E" href="http://en.wikipedia.org/wiki/Mixin"><http://en.wikipedia.org/wiki/Mixin></a><br> <br> Matt<br> <br> <span type="cite">John Beppu wrote:</span> </font></font> <p><font face="Arial,sans-serif" size="2"></font></p> <blockquote type="cite" style="border-left: thin solid blue; padding-left: 10px; margin-left: 0pt;"><font face="Arial,sans-serif" size="2">I get the concept of ''before'' and ''after'', and I think I understand ''around''. (It''s where you give it a function that does something, then yields to the original function, and when that returns, you run a little bit more code of your own.) <br> <br> The one thing I''m not sure about is ''introduction''. What does it mean to add an introduction?<br> <br> <br> <br> <br> </font></blockquote> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. <br> To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>