-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
I believe it's currently not possible to obtain a class' constructor name.
I'd like to do the following:
class Persistence
save: () =>
# apply some string manipulation wizardry and persist to database
console.log "Saving #{extractTableName @constructor.toString()}"
class Animal extends Persistence
class Horse extends Animal
(new Animal).save()
(new Horse).save()
Right now @constructor.toString()
will not yield the name because the constructor is an anonymous function assigned to a variable - and therefore doesn't have a name.
Would it be feasible to name the constructor function, in addition to the assignment, like so?
Horse = function Horse() {
return Animal.apply(this, arguments);
};