Hi,
Not sure what you mean by "scheme code," but I'm just talking about a
simple `for..in` loop. Off-the-cuff:
function createClass(superClass) {
var cls, name, value;
cls = Class.create.apply(Class, arguments);
// Is there a superclass?
if (Object.isFunction(superClass))
{
// Yes, see if it has any statics we should grab
for (name in superClass)
{
if (name !== 'prototype' &&
name !== 'addMethods' &&
// ...there will be several of these...
superClass.hasOwnProperty(name)
)
{
// A static, grab it
cls[name] = superClass[name];
}
}
}
return cls;
}
Something like that.
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com
On May 27, 3:06 pm, buda <[email protected]> wrote:
> T.J. could you provide what do you mean in scheme code, please
>
> Thanks
>
> On 27 май, 15:43, "T.J. Crowder" <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > > Is there a way to inheritate staticProp and staticMeth in inherited
> > > classes automatically?
>
> > Not built into `Class.create`, no. You could readily create a wrapper
> > for it that did that, though, looping through the "own" properties on
> > the superclass passed in and applying them to the resulting subclass
> > function. Important to be sure to skip over some that shouldn't be
> > copied, like -- to pick an example at random -- `prototype` (though I
> > don't think `prototype` is an enumerable property anyway, so it
> > shouldn't show up on a `for..in` loop). But there will be some to
> > skip, not least the ones Prototype puts on it like `addMethods`,
> > `superclass`, etc.
> > --
> > T.J. Crowder
> > Independent Software Engineer
> > tj / crowder software / com
> > www / crowder software / com
>
> > On May 27, 1:25 pm, buda <[email protected]> wrote:
>
> > > I use to do
>
> > > var Class1 = Class.create({
> > > ...
>
> > > });
>
> > > Object.extend(Class1, {
> > > staticProp: '',
> > > staticMeth: function(){...}
>
> > > })
>
> > > var Class2 = Class.create(Class1, {
> > > ....
>
> > > });
>
> > > Object.extend(Class2, {
> > > staticProp: '',
> > > staticMeth: function(){...}
>
> > > })
>
> > > Is there a way to inheritate staticProp and staticMeth in inherited
> > > classes automatically?
>
> > > Thanks
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.