From c62f6c16aabdbd4ff445460acbf859bae7865fb8 Mon Sep 17 00:00:00 2001 From: Daniel X Moore Date: Sat, 10 Jan 2015 14:26:17 -0800 Subject: [PATCH 1/2] This commit intentionally left blank From 445fe9960462fdca0046fd51e11d99e21711ee3f Mon Sep 17 00:00:00 2001 From: Daniel X Moore Date: Sun, 11 Jan 2015 08:21:24 -0800 Subject: [PATCH 2/2] :no_entry_sign::clock230: Updated in browser at strd6.github.io/editor --- main.coffee.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/main.coffee.md b/main.coffee.md index 1b4d9e3..e91ea4a 100644 --- a/main.coffee.md +++ b/main.coffee.md @@ -52,6 +52,38 @@ except the attribute is expected to be an array of models rather than a single o return self +`attrDatum` models an attribute as a data object. For example if our object has +a position attribute with x and y values we can do + +> self.attrDatum("position", Point) + +to promote the raw data into a Point data model available through a public +observable named position. + + attrDatum: (name, DataModel) -> + I[name] = model = DataModel(I[name]) + + self[name] = Observable(model) + + self[name].observe (newValue) -> + I[name] = newValue + + return self + +`attrData` models an array attribute as an observable array of data objects. + + attrData: (name, DataModel) -> + models = (I[name] or []).map (x) -> + DataModel(x) + + self[name] = Observable(models) + + self[name].observe (newValue) -> + I[name] = newValue.map (x) -> + DataModel(x) + + return self + The JSON representation is kept up to date via the observable properites and resides in `I`. toJSON: ->