play method
Runs another playbook here, in full: its setUp, steps and tearDown.
playbook is a Playbook or the name it's registered under. It gets
its own defaults, then this playbook's data, then data passed
here, and runs at this playbook's speed unless speed is given.
Implementation
PlaybookStep play(
Object playbook, {
Map<String, dynamic>? data,
PlaybookSpeed? speed,
}) {
if (playbook is! Playbook && playbook is! String) {
throw ArgumentError.value(
playbook,
'playbook',
'must be a Playbook or the name of a registered one',
);
}
final String title = playbook is Playbook
? PlaybookRegistry.nameOf(playbook)
: playbook as String;
return PlaybookGroupStep('Play $title', (
PlaybookActor actor,
PlaybookStepContext context,
) async {
final Playbook? child = playbook is Playbook
? playbook
: PlaybookRegistry.find(playbook as String);
if (child == null) {
final List<String> names = PlaybookRegistry.playbooks.keys.toList();
throw PlaybookFailure(
'There\'s no playbook called "$playbook".'
'${names.isEmpty ? '' : ' Registered: ${names.join(', ')}.'}',
);
}
final PlaybookReport report = await child.runWith(
actor.session,
speed: speed ?? actor.speed,
data: {...actor.data, ...?data},
emit: context.emit,
path: context.path,
depth: context.depth,
caption: context.caption,
);
return report.steps;
});
}