Skip to content

Instantly share code, notes, and snippets.

@trxcllnt
Created February 15, 2011 20:20
Show Gist options
  • Save trxcllnt/828166 to your computer and use it in GitHub Desktop.
Save trxcllnt/828166 to your computer and use it in GitHub Desktop.
package {
import flash.errors.IllegalOperationError;
import flash.utils.Dictionary;
import flash.utils.Proxy;
import flash.utils.flash_proxy;
use namespace flash_proxy;
public dynamic class ImmutableProxy extends Proxy {
private const propertyMap:Dictionary = new Dictionary();
override flash_proxy function getProperty(name:*):* {
return propertyMap[name];
}
override flash_proxy function setProperty(name:*, value:*):void {
if (name in propertyMap) {
throw new IllegalOperationError("Multiple mutation not supported.")
}
propertyMap[name] = value;
}
}
}
package {
import flash.utils.flash_proxy;
use namespace flash_proxy;
class ImmutableVO extends ImmutableProxy {
public function get property():* {
return flash_proxy::getProperty("property");
}
public function set property(value:*):void {
flash_proxy::setProperty("property", value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment