Joose class attributes

14 views
Skip to first unread message

fk1blow

unread,
Apr 12, 2011, 6:14:10 PM4/12/11
to Joose
I don't know how to explain this more clearly but here i go.

Basically i have a class like:
Class('BaseClass', {
has: {
a_attribute: {
init: null
},

b_attribute: {
init: null
}
}
});
all those attribute are for the Class instance.

What i need is a method to add some attributes(i mean attribute, not
static or class attributes) to that class, before i subclass or
instantiate it(and to have access to those attribute within a subclass
using this.attrName) - something like
BaseClass.meta.addAttribute('whatever', { init: 'asdasd' }) but this
method will give me an error - joose.js Mutation of closed property
set: [attributes];

The only method i can figure right now is
BaseClass.prototype.attribute to change the object's attribute(or add
it for that matter)

Regards

Nickolay Platonov

unread,
Apr 13, 2011, 1:43:26 AM4/13/11
to joos...@googlegroups.com
Hi,

You may need the mutability feature: http://joose.github.com/Joose/doc/html/Joose/Manual/Mutability.html

To add the "whatever" attribute to BaseClass (the same syntax as during attribute declaration):

BaseClass.meta.extend({
    has : {
        whatever : { ... }
    }
})

to remove some attribute from BaseClass:

BaseClass.meta.extend({
    hasnot : [ 'whatever' ]
})

Regards, Nickolay



--
You received this message because you are subscribed to the Google Groups "Joose" group.
To post to this group, send email to joos...@googlegroups.com.
To unsubscribe from this group, send email to joose-js+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joose-js?hl=en.


fk1blow

unread,
Apr 13, 2011, 5:38:28 AM4/13/11
to Joose
Thank you very very much Nickolay, that worked.

Regards, Dragos
Reply all
Reply to author
Forward
0 new messages