96 lines
1.9 KiB
Smalltalk
96 lines
1.9 KiB
Smalltalk
"
|
|
I represent a operation that can be done on data inputs to produce and output by executing
|
|
a code block.
|
|
|
|
I can be used by BreaThemes to produce outpus reflected in a particular set of theme pages.
|
|
|
|
|
|
- (for bonus points) how to create instances.
|
|
|
|
One simple example is simply gorgeous.
|
|
|
|
Internal Representation and Key Implementation Points.
|
|
|
|
Instance Variables
|
|
codeBlock: <Object>
|
|
inputs: <Object>
|
|
name: <Object>
|
|
|
|
|
|
Implementation Points
|
|
"
|
|
Class {
|
|
#name : #BreaOperator,
|
|
#superclass : #Object,
|
|
#instVars : [
|
|
'name',
|
|
'inputs',
|
|
'codeBlock',
|
|
'cleanedInputs'
|
|
],
|
|
#category : #Brea
|
|
}
|
|
|
|
{ #category : #converting }
|
|
BreaOperator >> asSton [
|
|
^ STON toStringPretty: self
|
|
]
|
|
|
|
{ #category : #converting }
|
|
BreaOperator >> cleanInputs [
|
|
self cleanedInputs ifNil: [ ^ self ].
|
|
self cleanedInputs ifTrue: [
|
|
self inputs keysAndValuesDo: [ :k :v | | currentValue |
|
|
currentValue := self inputs at: k.
|
|
self inputs at: k put: currentValue class new
|
|
]
|
|
].
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> cleanedInputs [
|
|
^ cleanedInputs
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> cleanedInputs: aBoolean [
|
|
"I tell if the inputs should be cleaned when the query is serialized as STON, for
|
|
example when they contain sensible information, like API keys or passwords"
|
|
cleanedInputs := aBoolean
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> codeBlock [
|
|
^ codeBlock
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> codeBlock: anObject [
|
|
codeBlock := anObject
|
|
]
|
|
|
|
{ #category : #execution }
|
|
BreaOperator >> execute [
|
|
^ self codeBlock valueWithArguments: self inputs values.
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> inputs [
|
|
^ inputs
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> inputs: anOrderedDictionary [
|
|
inputs := anOrderedDictionary
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> name [
|
|
^ name
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
BreaOperator >> name: anObject [
|
|
name := anObject
|
|
]
|