Add methods #65

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@fntz
fntz commented Sep 8, 2012

Hi.

I updated the method addMethod. Now you can set variables before add module into object.
For example:

 //Before
 var Module: {
   setup: function() {
     this.variable = 'some var';
   }
 };
 //and Class
 var C = Class.create({
   initialize: function() {
     this.setup();
   }
 });
 C.addMethods(Module);

 //Now:
 var Module: {};
 var C = Class.create({});
 C.addMethods(Module, function() { this.variable = 'some var'; });
@savetheclocktower
Collaborator

So you want some sort of included hook for mixins, like in Ruby? It's a possibility in the future, but likely not until 2.0. The class system is designed to have as little "magic" as possible, and I'd rather not introduce new conventions until we have a chance to reimagine the whole system from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment