Difference between 'has' and 'have'

4 views
Skip to first unread message

nickf

unread,
Dec 7, 2010, 6:12:11 AM12/7/10
to Joose
Could you explain the difference between the builder "has" and "have"?
The documentation kinda makes it look like these two are equivalent:

Class({
"have" : {
foo : 'bar'
}
});

Class({
has : {
foo : { init : 'bar' }
}
});


... but it doesn't seem to work that way.

Nickolay Platonov

unread,
Dec 7, 2010, 7:05:21 AM12/7/10
to joos...@googlegroups.com
On Tue, Dec 7, 2010 at 2:12 PM, nickf <spa...@gmail.com> wrote:
Could you explain the difference between the builder "has" and "have"?
The documentation kinda makes it look like these two are equivalent:

Class({
   "have" : {
       foo : 'bar'
   }
});

with "have" "foo" is a "basic" attribute, whatever its value is ("bar") it just goes into the prototype of the class
 
Class({
   has : {
       foo : { init : 'bar' }
   }
});

Here "foo" is "advanced" attribute, it may have accessors and various other features. The "init" property goes into the prototype, unless its a function.
If its a function, it will be called during initialization to provide initial value.


... but it doesn't seem to work that way.

It should work the same way, how exactly its different for you?

nickf

unread,
Dec 7, 2010, 9:22:54 AM12/7/10
to Joose
Ah ok, so "haves" don't create a Joose.Managed.Attribute instance?

I had some code that was expected the attributes to always be advanced
ones, I guess.

On Dec 7, 1:05 pm, Nickolay Platonov <nickol...@gmail.com> wrote:

Nickolay Platonov

unread,
Dec 7, 2010, 9:25:26 AM12/7/10
to joos...@googlegroups.com
On Tue, Dec 7, 2010 at 5:22 PM, nickf <spa...@gmail.com> wrote:
Ah ok, so "haves" don't create a Joose.Managed.Attribute instance?

Nope, it creates Joose.Managed.Property.Attribute instances (Joose.Managed.Attribute is a subclass of this class)
Reply all
Reply to author
Forward
0 new messages