Confusion constructing a composite class

11 views
Skip to first unread message

Matt Williams

unread,
Mar 26, 2011, 10:51:54 PM3/26/11
to Joose
I have a composite class (User) which I am constructing with json
data.
I appear to be able to access the properties but do not have access to
the methods of the component (User.Name).
Am I going about this in the wrong way?

Thanks

Matt

=====================

var Class = require('joose').Class;

Class('User.Name', {
has: {
forename: {
is: "rw",
},
surname: {
is: "rw"
}
}
});

Class('User', {
has: {
name: {
isa: User.Name,
is: "rw"
},
nickname: {
is: "rw",
}
}
});

var user = new User({
nickname: "smithy",
name: {
forename: "john",
surname: "smith"
}
});

console.log(user.getName().surname) // Outputs: smith
console.log(user.getName().getSurname()); // Outputs Error: Object
#<Object> has no method 'getSurname'

Nickolay Platonov

unread,
Mar 27, 2011, 5:29:59 AM3/27/11
to joos...@googlegroups.com
"isa" for attributes is not yet supported in Joose3. Your snippet should be written as:


var Class = require('joose').Class;

Class('User.Name', {
       has: {
               forename: {
                       is: "rw",
               },
               surname: {
                       is: "rw"
               }
       }
});

Class('User', {
       has: {
               name: {
                       is: "rw"
               },
               nickname: {
                       is: "rw",
               }
       }
});

var user = new User({
       nickname: "smithy",

       name: new User.Name({

               forename: "john",
               surname: "smith"
       })
});


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.


Reply all
Reply to author
Forward
0 new messages