Browse Source

Refactor former registerIn:.

Herbert Vojčík 6 years ago
parent
commit
fb1ec7b8f5
4 changed files with 42 additions and 44 deletions
  1. 3 3
      src/Axxord-Tests.js
  2. 1 1
      src/Axxord-Tests.st
  3. 31 31
      src/Axxord.js
  4. 7 9
      src/Axxord.st

+ 3 - 3
src/Axxord-Tests.js

@@ -624,7 +624,7 @@ return $core.withContext(function($ctx1) {
 result=nil;
 model=$globals.HashedCollection._newFromPairs_(["foo",["bar", [(1), [(2), (3)]], "baz"],"moo","zoo"]);
 axon=$recv($globals.TestSpyAxon)._new();
-$recv(axon)._registerIn_(model);
+$recv(model)._axxord_(axon);
 $recv(model)._axes_transform_(["foo", (2)],(function(r){
 return "new";
 
@@ -637,10 +637,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testModelTransformSentToAxon\x0a| model result axon |\x0aresult := nil.\x0amodel := #{ 'foo' -> #('bar' #(1 #(2 3)) 'baz'). 'moo' -> 'zoo' }.\x0aaxon := TestSpyAxon new.\x0aaxon registerIn: model.\x0amodel axes: #(foo 2) transform: [:r | #new].\x0aself assert: axon changedAspectLog equals: #((foo 2))",
+source: "testModelTransformSentToAxon\x0a| model result axon |\x0aresult := nil.\x0amodel := #{ 'foo' -> #('bar' #(1 #(2 3)) 'baz'). 'moo' -> 'zoo' }.\x0aaxon := TestSpyAxon new.\x0amodel axxord: axon.\x0amodel axes: #(foo 2) transform: [:r | #new].\x0aself assert: axon changedAspectLog equals: #((foo 2))",
 referencedClasses: ["TestSpyAxon"],
 //>>excludeEnd("ide");
-messageSends: ["new", "registerIn:", "axes:transform:", "assert:equals:", "changedAspectLog"]
+messageSends: ["new", "axxord:", "axes:transform:", "assert:equals:", "changedAspectLog"]
 }),
 $globals.PlainConsumeTransformTest);
 

+ 1 - 1
src/Axxord-Tests.st

@@ -146,7 +146,7 @@ testModelTransformSentToAxon
 result := nil.
 model := #{ 'foo' -> #('bar' #(1 #(2 3)) 'baz'). 'moo' -> 'zoo' }.
 axon := TestSpyAxon new.
-axon registerIn: model.
+model axxord: axon.
 model axes: #(foo 2) transform: [:r | #new].
 self assert: axon changedAspectLog equals: #((foo 2))
 !

+ 31 - 31
src/Axxord.js

@@ -570,30 +570,6 @@ messageSends: ["ifTrue:", "fork", "run"]
 }),
 $globals.Axon);
 
-$core.addMethod(
-$core.method({
-selector: "registerIn:",
-protocol: "injecting",
-fn: function (anObject){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-anObject.$axon$=self;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"registerIn:",{anObject:anObject},$globals.Axon)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anObject"],
-source: "registerIn: anObject\x0a<inlineJS: 'anObject.$axon$=self'>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Axon);
-
 $core.addMethod(
 $core.method({
 selector: "run",
@@ -1544,7 +1520,7 @@ throw $early=[self];
 
 }),newValue);
 }
-$2=$self._registeredAxon();
+$2=$self._axxord();
 if(($receiver = $2) == null || $receiver.a$nil){
 $2;
 } else {
@@ -1561,31 +1537,55 @@ catch(e) {if(e===$early)return e[0]; throw e}
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aCollection", "aBlock"],
-source: "axes: aCollection transform: aBlock\x0a\x09| value newValue |\x0a\x09value := self atAxes: aCollection ifAbsent: [ ^self ].\x0a\x09newValue := aBlock value: value.\x0a\x09value == newValue ifFalse: [ self atAxes: aCollection ifAbsent: [ ^self ] put: newValue ].\x0a\x09self registeredAxon ifNotNil: [:axon | axon changed: aCollection]",
+source: "axes: aCollection transform: aBlock\x0a\x09| value newValue |\x0a\x09value := self atAxes: aCollection ifAbsent: [ ^self ].\x0a\x09newValue := aBlock value: value.\x0a\x09value == newValue ifFalse: [ self atAxes: aCollection ifAbsent: [ ^self ] put: newValue ].\x0a\x09self axxord ifNotNil: [:axon | axon changed: aCollection]",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["atAxes:ifAbsent:", "value:", "ifFalse:", "==", "atAxes:ifAbsent:put:", "ifNotNil:", "registeredAxon", "changed:"]
+messageSends: ["atAxes:ifAbsent:", "value:", "ifFalse:", "==", "atAxes:ifAbsent:put:", "ifNotNil:", "axxord", "changed:"]
 }),
 $globals.Object);
 
 $core.addMethod(
 $core.method({
-selector: "registeredAxon",
+selector: "axxord",
 protocol: "*Axxord",
 fn: function (){
 var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return self.$axon$;
+return self.$axxord$;
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"registeredAxon",{},$globals.Object)});
+}, function($ctx1) {$ctx1.fill(self,"axxord",{},$globals.Object)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "registeredAxon\x0a<inlineJS: 'return self.$axon$'>",
+source: "axxord\x0a<inlineJS: 'return self.$axxord$'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.Object);
+
+$core.addMethod(
+$core.method({
+selector: "axxord:",
+protocol: "*Axxord",
+fn: function (anAxon){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+self.$axxord$ = anAxon;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"axxord:",{anAxon:anAxon},$globals.Object)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anAxon"],
+source: "axxord: anAxon\x0a<inlineJS: 'self.$axxord$ = anAxon'>",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: []

+ 7 - 9
src/Axxord.st

@@ -135,12 +135,6 @@ run
 	] on: Error do: [ self dirty: true ]
 ! !
 
-!Axon methodsFor: 'injecting'!
-
-registerIn: anObject
-<inlineJS: 'anObject.$axon$=self'>
-! !
-
 Axon subclass: #SimpleAxon
 	instanceVariableNames: 'queue'
 	package: 'Axxord'!
@@ -341,11 +335,15 @@ axes: aCollection transform: aBlock
 	value := self atAxes: aCollection ifAbsent: [ ^self ].
 	newValue := aBlock value: value.
 	value == newValue ifFalse: [ self atAxes: aCollection ifAbsent: [ ^self ] put: newValue ].
-	self registeredAxon ifNotNil: [:axon | axon changed: aCollection]
+	self axxord ifNotNil: [:axon | axon changed: aCollection]
+!
+
+axxord
+<inlineJS: 'return self.$axxord$'>
 !
 
-registeredAxon
-<inlineJS: 'return self.$axon$'>
+axxord: anAxon
+<inlineJS: 'self.$axxord$ = anAxon'>
 ! !
 
 !String methodsFor: '*Axxord'!