Skip to content

Instantly share code, notes, and snippets.

@ericf
Forked from kara-ryli/definition.js
Created March 12, 2011 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericf/867093 to your computer and use it in GitHub Desktop.
Save ericf/867093 to your computer and use it in GitHub Desktop.
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'
}
}
});
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