import Injector from './injector';

function injectServices(obj) {
  console.log('Injecting...');
  for (var prop in obj) {
    var val = obj[prop];
    if (val instanceof Injector) {
      console.log('Injecting ' + val);
      obj[prop] = val.service();
    }
  }
}

export default function jedify(klass) {
  if (klass._jedi) {
    return klass;
  } else {
    var JediClass = class JediClass extends klass {
      constructor(...args) {
        super(...args);
        injectServices(this);
      }
    };

    JediClass._jedi = true;
    return JediClass;
  }
}

@@ -32,71 +32,125 @@
 r';%0A
-%0Afunction injectServices(obj) %7B%0A  console.log('Injecting...'
+import Container from './container';%0A%0Afunction injectServices(obj) %7B%0A  var container = Container.containerFor(obj
 );%0A
+%0A
   fo
@@ -235,47 +235,8 @@
 ) %7B%0A
-      console.log('Injecting ' + val);%0A
     
@@ -261,16 +261,25 @@
 service(
+container
 );%0A    %7D
@@ -290,117 +290,52 @@
 %0A%7D%0A%0A
-export default function jedify(klass) %7B%0A  if (klass._jedi
+function injectConstructor(klass
 ) %7B%0A  
- 
- 
 return
- klass;%0A  %7D else %7B%0A    var JediClass =
  cla
@@ -367,18 +367,16 @@
 s %7B%0A    
-  
 construc
@@ -386,26 +386,24 @@
 (...args) %7B%0A
-  
       super(
@@ -418,18 +418,16 @@
 ;%0A      
-  
 injectSe
@@ -448,17 +448,152 @@
     
-  %7D%0A    %7D
+%7D%0A  %7D;%0A%7D%0A%0Aexport default function jedify(klass) %7B%0A  if (klass._jedi) %7B%0A    return klass;%0A  %7D else %7B%0A    var JediClass = injectConstructor(klass)
 ;%0A%0A 

Initialize object w/ stored container.