-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathCommandMapper.as
118 lines (102 loc) · 3.17 KB
/
CommandMapper.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//------------------------------------------------------------------------------
// Copyright (c) 2009-2013 the original author or authors. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//------------------------------------------------------------------------------
package robotlegs.bender.extensions.commandCenter.impl
{
import robotlegs.bender.extensions.commandCenter.api.ICommandMapping;
import robotlegs.bender.extensions.commandCenter.api.ICommandMappingList;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandConfigurator;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandMapper;
import robotlegs.bender.extensions.commandCenter.dsl.ICommandUnmapper;
/**
* @private
*/
public class CommandMapper implements ICommandMapper, ICommandUnmapper, ICommandConfigurator
{
/*============================================================================*/
/* Private Properties */
/*============================================================================*/
private var _mappings:ICommandMappingList;
private var _mapping:ICommandMapping;
/*============================================================================*/
/* Constructor */
/*============================================================================*/
/**
* Creates a Command Mapper
* @param mappings The command mapping list to add mappings to
*/
public function CommandMapper(mappings:ICommandMappingList)
{
_mappings = mappings;
}
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
/**
* @inheritDoc
*/
public function toCommand(commandClass:Class):ICommandConfigurator
{
_mapping = new CommandMapping(commandClass);
_mappings.addMapping(_mapping);
return this;
}
/**
* @inheritDoc
*/
public function fromCommand(commandClass:Class):void
{
_mappings.removeMappingFor(commandClass);
}
/**
* @inheritDoc
*/
public function fromAll():void
{
_mappings.removeAllMappings();
}
/**
* @inheritDoc
*/
public function once(value:Boolean = true):ICommandConfigurator
{
_mapping.setFireOnce(value);
return this;
}
/**
* @inheritDoc
*/
public function withGuards(... guards):ICommandConfigurator
{
_mapping.addGuards.apply(null, guards);
return this;
}
/**
* @inheritDoc
*/
public function withHooks(... hooks):ICommandConfigurator
{
_mapping.addHooks.apply(null, hooks);
return this;
}
/**
* @inheritDoc
*/
public function withExecuteMethod(name:String):ICommandConfigurator
{
_mapping.setExecuteMethod(name);
return this;
}
/**
* @inheritDoc
*/
public function withPayloadInjection(value:Boolean = true):ICommandConfigurator
{
_mapping.setPayloadInjectionEnabled(value);
return this;
}
}
}