Sedux.st 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Smalltalk createPackage: 'Sedux'!
  2. Object subclass: #SeduxCreatorClass
  3. instanceVariableNames: ''
  4. package: 'Sedux'!
  5. !SeduxCreatorClass class methodsFor: 'as yet unclassified'!
  6. << aStoreEnhancer
  7. ^ aStoreEnhancer next: self
  8. !
  9. inject: anObject
  10. ^ self inject: anObject into: nil
  11. ! !
  12. SeduxCreatorClass subclass: #Sedux
  13. instanceVariableNames: ''
  14. package: 'Sedux'!
  15. !Sedux class methodsFor: 'as yet unclassified'!
  16. dispatch: anAction with: aReceiver fallback: aBlock
  17. ^ (aReceiver respondsTo: anAction selector)
  18. ifTrue: [ anAction sendTo: aReceiver ]
  19. ifFalse: aBlock
  20. !
  21. inject: aReducer into: anObject
  22. "Creates a store, dispatches initiating message"
  23. ! !
  24. SeduxCreatorClass subclass: #SeduxDecorator
  25. instanceVariableNames: 'next'
  26. package: 'Sedux'!
  27. !SeduxDecorator methodsFor: 'accessing'!
  28. next: anObject
  29. next := anObject
  30. ! !
  31. SeduxDecorator class instanceVariableNames: 'next'!
  32. !SeduxDecorator class methodsFor: 'as yet unclassified'!
  33. inject: aReducer into: anObject
  34. ^ SeduxDecoratedStore dispatch: self new next: (self nextInject: aReducer into: anObject)
  35. !
  36. next: aStoreCreator
  37. next := aStoreCreator.
  38. ^self
  39. !
  40. nextInject: aReducer into: anObject
  41. ^ next inject: aReducer into: anObject
  42. ! !
  43. SeduxDecorator subclass: #SeduxFoo
  44. instanceVariableNames: ''
  45. package: 'Sedux'!
  46. Object subclass: #SeduxDecoratedStore
  47. instanceVariableNames: 'next dispatch'
  48. package: 'Sedux'!
  49. !SeduxDecoratedStore methodsFor: 'accessing'!
  50. dispatch: anAction
  51. ^ Sedux
  52. dispatch: anAction
  53. with: dispatch
  54. fallback: [ ^ next dispatch: anAction ]
  55. !
  56. dispatch: aDispatcher next: aStore
  57. dispatch := aDispatcher.
  58. next := aStore
  59. ! !
  60. !SeduxDecoratedStore class methodsFor: 'instance creation'!
  61. dispatch: aDispatcher next: aStore
  62. ^ self new
  63. dispatch: aDispatcher next: aStore;
  64. yourself
  65. ! !