-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finel the prototype - send to Itzik for review
- Loading branch information
Michael Solomon
committed
Jun 24, 2015
1 parent
7302f5e
commit 6bdcefb
Showing
7 changed files
with
167 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package; | ||
|
||
/** | ||
* ... | ||
* @author Michael | ||
*/ | ||
class SampleAbstract | ||
{ | ||
var cookies; | ||
public function new() { | ||
cookies = new SimpleCookie(); | ||
Cookie.set("complex", "a=b,b=c"); | ||
var cookiesMap:StringMap<String> = Cookie.all(); | ||
for (name in cookiesMap.keys()) { | ||
var subValues:Array<String> = cookiesMap.get(name).split(","); | ||
if (subValues.length > 1) { | ||
cookies[name] = { }; | ||
for (pair in subValues) { | ||
cookies[name][pair.split("=")[0]] = pair.split("=")[1]; | ||
} | ||
}else { | ||
cookies[name] = subValues[0]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
class SubCookie { | ||
public function new() {} | ||
@:keep public function toString() | ||
return haxe.Json.stringify(this); | ||
} | ||
|
||
abstract SimpleCookie(Dynamic) to Dynamic { | ||
public inline function new() this = new SubCookie(); | ||
@:arrayAccess function get(key:String):SimpleCookie { | ||
if (!Reflect.hasField(this, key)) | ||
Reflect.setField(this, key, new SubCookie()); | ||
return Reflect.field(this, key); | ||
} | ||
@:arrayAccess function setString(key:String, value:String):String { | ||
Reflect.setField(this, key, value); | ||
return value; | ||
} | ||
|
||
@:arrayAccess function setDynamic(key:String, value:Dynamic):Dynamic { | ||
Reflect.setField(this, key, value); | ||
return value; | ||
} | ||
|
||
public inline function keys() | ||
return Reflect.fields(this); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.