-
-
Save ericf/867093 to your computer and use it in GitHub Desktop.
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 characters
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); | |
} | |
}, { | |
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 characters
var instance = new MyClass({ | |
dict: { | |
test: true | |
} | |
}); | |
instance.get('dict'); // { foo: 'bar', test: true } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment