-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRequestContainer.cfc
More file actions
61 lines (45 loc) · 1.54 KB
/
RequestContainer.cfc
File metadata and controls
61 lines (45 loc) · 1.54 KB
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
component implements = "IContainer" {
RequestContainer function init(string name) {
variables.name = structKeyExists(arguments, "name") ? arguments.name : "rc_#getTickCount()#";
request[variables.name] = {};
return this;
}
void function clear() {
structClear(request[variables.name]);
}
boolean function containsKey(required string key) {
return structKeyExists(request, variables.name) && structKeyExists(request[variables.name], arguments.key);
}
void function destroy() {
structDelete(request, variables.name);
}
any function get(required string key) {
if(containsKey(arguments.key)) {
return request[variables.name][arguments.key];
}
}
boolean function isEmpty() {
return !structKeyExists(request, variables.name) || structIsEmpty(request[variables.name]);
}
string function keyList() {
if(structKeyExists(request, variables.name)) {
return listSort(structKeyList(request[variables.name]), "textnocase");
}
return "";
}
void function put(required string key, required any value) {
request[variables.name][arguments.key] = arguments.value;
}
void function putAll(required struct values, boolean clear = false, boolean overwrite = false) {
if(arguments.clear) {
this.clear();
}
structAppend(request[variables.name], arguments.values, arguments.overwrite);
}
void function remove(required string key) {
structDelete(request[variables.name], arguments.key);
}
struct function values() {
return duplicate(request[variables.name]);
}
}