-
-
Save ericf/867093 to your computer and use it in GitHub Desktop.
Revisions
-
ericf revised this gist
Mar 12, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ var MyClass = Y.Base.create('my-class', Y.Base, [], { _mergeProps: function (value, prop) { var cur = this.get(prop); if (Y.Lang.isUndefined(cur)) { this.reset(prop); // will rest to { test: true } for this instance instead of always using the static default values } return Y.merge(cur, value); } -
kara-ryli created this gist
Mar 10, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ var MyClass = Y.Base.create('my-class', Y.Base, [], { _mergeProps: function (value, prop) { var cur = this.get(prop); if (Y.Lang.isUndefined(cur)) { cur = this.constructor.ATTRS[prop].value; } return Y.merge(cur, value); } }, { ATTRS: { dict: { value: { foo: 'bar', test: false }, setter: '_mergeProps' } } }); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ var instance = new MyClass({ dict: { test: true } }); instance.get('dict'); // { foo: 'bar', test: true }