Trapped-Backend.st 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. Smalltalk createPackage: 'Trapped-Backend'!
  2. (Smalltalk packageAt: 'Trapped-Backend') imports: {'axxord/Axxord'}!
  3. Object subclass: #Isolator
  4. instanceVariableNames: 'root'
  5. package: 'Trapped-Backend'!
  6. !Isolator methodsFor: 'accessing'!
  7. root
  8. ^root
  9. !
  10. root: anObject
  11. root := anObject
  12. ! !
  13. !Isolator methodsFor: 'action'!
  14. model: anEavModel modify: aBlock
  15. | newValue |
  16. newValue := aBlock value: (anEavModel on: self).
  17. anEavModel on: self put: newValue deepCopy
  18. !
  19. model: anEavModel read: aBlock
  20. aBlock value: (anEavModel on: self) deepCopy
  21. ! !
  22. !Isolator class methodsFor: 'instance creation'!
  23. on: anObject
  24. ^self new root: anObject
  25. ! !
  26. Object subclass: #TrappedPosition
  27. instanceVariableNames: 'path model'
  28. package: 'Trapped-Backend'!
  29. !TrappedPosition methodsFor: 'accessing'!
  30. model
  31. ^model
  32. !
  33. path
  34. ^path
  35. !
  36. path: anArray model: aTrappedMW
  37. path := anArray.
  38. model := aTrappedMW
  39. ! !
  40. !TrappedPosition methodsFor: 'action'!
  41. modify: aBlock
  42. self model axes: self path transform: aBlock
  43. !
  44. read: aBlock
  45. self model axes: self path consume: aBlock
  46. !
  47. watch: aBlock
  48. self model registeredAxon addInterest: (self
  49. interestOn: self path
  50. block: [ self read: aBlock ])
  51. ! !
  52. !TrappedPosition methodsFor: 'private'!
  53. interestOn: anAspect block: aBlock
  54. (anAspect notEmpty and: [ anAspect last isNil ])
  55. ifTrue: [ ^ InterestedThruAxes new aspect: anAspect allButLast block: aBlock ]
  56. ifFalse: [ ^ InterestedUpToAxes new aspect: anAspect block: aBlock ]
  57. ! !