text: var logger = require('./logger');
  var api = {};
  var ember = null;
  var hookedFactories = {};
  
  api.getEmber = function () {
  	if (ember) {
  		return ember;
  	}
  	if (window.App && window.App.__container__) {
  		ember = window.App.__container__;
  		return ember;
  	}
  	return false;
  };
  
  api.isLoaded = function () {
  	return Boolean(api.getEmber());
  };
  
  api.lookup = function (lookupFactory) {
  	if (!api.isLoaded()) {
  		logger.debug('Factory lookup failure, Ember not loaded.');
  		return false;
  	}
  	return api.getEmber().lookup(lookupFactory);
  };
  
  api.hook = function (lookupFactory, activateCb, deactivateCb) {
  	if (!api.isLoaded()) {
  		logger.debug('Factory hook failure, Ember not loaded.');
  		return false;
  	}
  	if (hookedFactories[lookupFactory]) {
  		logger.debug('Factory already hooked: ' + lookupFactory);
  		return true;
  	}
  	var reopenOptions = {};
  	var factory = api.lookup(lookupFactory);
  
  	if (!factory) {
  		logger.debug('Factory hook failure, factory not found: ' + lookupFactory);
  		return false;
  	}
  
  	if (activateCb) {
  		reopenOptions.activate = function () {
  			this._super();
  			activateCb.call(this);
  			logger.debug('Hook run on activate: ' + lookupFactory);
  		};
  	}
  	if (deactivateCb) {
  		reopenOptions.deactivate = function () {
  			this._super();
  			deactivateCb.call(this);
  			logger.debug('Hook run on deactivate: ' + lookupFactory);
  		};
  	}
  
  	try {
  		factory.reopen(reopenOptions);
  		hookedFactories[lookupFactory] = true;
  		logger.debug('Factory hooked: ' + lookupFactory);
  		return true;
  	}
  	catch (err) {
  		logger.debug('Factory hook failure, unexpected error: ' + lookupFactory);
  		logger.debug(err);
  		return false;
  	}
  };
  
  api.get = function (lookupFactory, property) {
  	if (!api.isLoaded()) {
  		logger.debug('Factory get failure, Ember not loaded.');
  		return false;
  	}
  	var properties = property.split('.');
  	var getter = api.lookup(lookupFactory);
  
  	properties.some(function (property) {
  		// If getter fails, just exit, otherwise, keep looping.
  		if (getter == null || typeof getter === 'undefined') {
  			getter = null;
  			return true;
  		}
  		if (getter[property] == null || typeof getter[property] === 'undefined') {
  			getter = null;
  			return true;
  		}
  		if (typeof getter.get === 'function') {
  			getter = getter.get(property);
  			if (getter == null || typeof getter === 'undefined') {
  				getter = null;
  				return true;
  			}
  			return false;
  		}
  		getter = getter[property];
  	});
  
  	return getter;
  };
  
  module.exports = api;
  