--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plug.st Sun Mar 26 17:05:23 1995 +0200
@@ -0,0 +1,80 @@
+'From Smalltalk/X, Version:2.10.5 on 26-mar-1995 at 12:13:28 pm'!
+
+Object subclass:#Plug
+ instanceVariableNames:'simulatedProtocol'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Kernel-Objects'
+!
+
+!Plug class methodsFor:'documentation'!
+
+version
+"
+$Header: /cvs/stx/stx/libview2/Plug.st,v 1.1 1995-03-26 15:05:23 claus Exp $
+"
+!
+
+documentation
+"
+ A Plug is an objcet which simulates a protocol and evaluates
+ a corresponding block when receiving messages.
+ Its main use is for the demo doIts, to play the role of a model.
+ Plugs are not used in the system and exist as a demo only.
+ This class may be changed/removed/replaced without notice.
+"
+!
+
+examples
+"
+ |plug|
+
+ plug := Plug new.
+ plug respondTo:#foo with:[Transcript showCr:'received foo'].
+ plug respondTo:#foo: with:[:arg | Transcript showCr:'received foo: ', arg printString].
+
+ plug foo.
+ plug foo:'some argument'
+"
+! !
+
+!Plug class methodsFor:'initialization'!
+
+initialize
+ superclass := nil
+! !
+
+!Plug class methodsFor:'instance creation'!
+
+new
+ ^ super basicNew privateInitialize
+! !
+
+!Plug methodsFor:'protocol definition'!
+
+respondTo:aSelector with:aBlock
+ simulatedProtocol at:aSelector put:aBlock
+! !
+
+!Plug methodsFor:'message sending'!
+
+doesNotUnderstand:aMessage
+ |block|
+
+ block := simulatedProtocol at:aMessage selector ifAbsent:[].
+ block isNil ifTrue:[
+ ^ super doesNotUnderstand:aMessage
+ ].
+ ^ block valueWithArguments:(aMessage arguments)
+! !
+
+!Plug methodsFor:'initialization'!
+
+privateInitialize
+ "this method is NOT called initialize to allow plugging that
+ selector ..."
+
+ simulatedProtocol := IdentityDictionary new.
+! !
+
+Plug initialize!