On Thu, Mar 24, 2016 at 4:02 PM, Denis Kudriashov <[email protected]> wrote:
> Hi. > Thank's for kind words. > > 2016-03-24 19:22 GMT+01:00 Mariano Martinez Peck <[email protected]>: > >> >>> - GHClassGhost able to replace class of real objects. It implements >>> cannotInterpret: trick to intercept all instance messages. Subclasses >>> should define two behaviours: #ghostBehaviour (as any other ghost) and >>> #instancesBehaviour which will process instance messages. In previous >>> version it was different message to same #ghostBehaviour. >>> >>> > In your original version you implemented #cannotInterpert: for instance > messages such way: > proxy proxyHandler *handleInterceptionToInstance:* interception. > And proxy handler was responsible for two messages: > #handleInterceptionToInstance: > and #handleInterception:. > In my version I ask proxy for different kind of handler (ghostBehaviour): > > GHObjectGhost>>doesNotUnderstand: aMessage > > self *ghostBehaviour* intercept: aMessage to: self > > > GHInstanceMessagesInterceptor>>cannotInterpret: aMessage > > "some logic to find ghostClass" > > ghostClass *instancesBehaviour* intercept: aMessage to: self > > > OK, that's good. I like it. > >>> - New kind of proxies: >>> - GHObjectVirus. It is special kind of GHClassProxy. It infects real >>> object to intercept it messages. From meta level infected object >>> looks like >>> healthy object which means that meta messages are executed by infected >>> object itself. As class virus looks like real victim class. So in >>> case when >>> virus is created with standard meta level tools will not differ him >>> from >>> health object. There are special messages which allow ask object about >>> viruses: >>> - infectedObject isInfectedByVirus >>> - infectedObject virus >>> - infectedObject recoverFromVirus >>> >>> >> Sorry I did not get this one. >> > > Good example where I use viruses is stubbing real objects in Mocketry. I > will announce it soon. You can do this: > > rect := 0@0 corner: 2@3 > rect stub area willReturn: 1000. > > rect area "=> 1000". > rect origin "=> 0@0". > > > OK..I should take a look to the code...but...it looks to me that stub the only thing it does is to create the proxy and then the #become: ?? -- Mariano http://marianopeck.wordpress.com
