Skip to content
Permalink
Browse files

Renamed #canBeRun as #canBeExecuted to be more consistent.

Created a deprecation to ease migration of users.
  • Loading branch information...
juliendelplanque committed Aug 10, 2019
1 parent 813cda2 commit 152e6a72261a8f1f6fb4e9ad579a199b73dba036
@@ -11,5 +11,6 @@ BaselineOfCommander2 >> baseline: spec [
spec for: #common do: [
spec
package: 'Commander2';
package: 'Commander2-Deprecations' with: [ spec requires: #('Commander2') ];
package: 'Commander2-Tests' ]
]
@@ -0,0 +1,7 @@
Extension { #name : #CmAbstractCommand }

{ #category : #'*Commander2-Deprecations' }
CmAbstractCommand >> canBeRun [
self deprecated: 'Use #canBeExecuted instead.' transformWith: '`@receiver canBeRun' -> '`@receiver canBeExecuted'.
^ self canBeExecuted
]
@@ -0,0 +1 @@
Package { #name : #'Commander2-Deprecations' }
@@ -24,12 +24,12 @@ CmCommandTest >> testBasicName [
]

{ #category : #test }
CmCommandTest >> testCanBeRun [
CmCommandTest >> testCanBeExecuted [
command context: 0. "Need to set context before because the command expects it."
self deny: command canBeRun.
self deny: command canBeExecuted.

command context: 42.
self assert: command canBeRun.
self assert: command canBeExecuted.
]

{ #category : #test }
@@ -5,7 +5,7 @@ Class {
}

{ #category : #testing }
CmFakeCommand >> canBeRun [
CmFakeCommand >> canBeExecuted [
^ self context = 42
]

@@ -15,7 +15,7 @@ CmAbstractCommand >> acceptVisitor: aCmCommandOrGroup [
]

{ #category : #testing }
CmAbstractCommand >> canBeRun [
CmAbstractCommand >> canBeExecuted [
"This hook allows the command decide if it can be run with the context it holds or not.
It should return a boolean.
"
@@ -24,9 +24,9 @@ CmBlockCommand >> block: anObject [
]

{ #category : #testing }
CmBlockCommand >> canBeRun [
CmBlockCommand >> canBeExecuted [
self hasContext "When no context is set, we consider the command to be runnable. So we call super."
ifFalse: [ ^ super canBeRun ].
ifFalse: [ ^ super canBeExecuted ].

^ self canBeRunBlock value: self context
]
@@ -59,7 +59,7 @@ CmCommand class >> runWith: anObject [
]

{ #category : #testing }
CmCommand >> canBeRun [
CmCommand >> canBeExecuted [
"See my super class comment for this method.
By default I return true.
"
@@ -35,11 +35,11 @@ CmCommandDecorator >> basicName: aString [
]

{ #category : #testing }
CmCommandDecorator >> canBeRun [
CmCommandDecorator >> canBeExecuted [
"This hook allows the command decide if it can be run with the context it holds or not.
It should return a boolean.
"
^ self decoratedCommand canBeRun
^ self decoratedCommand canBeExecuted
]

{ #category : #accessing }

0 comments on commit 152e6a7

Please sign in to comment.
You can’t perform that action at this time.