vendor/assets/javascripts/angularjs/rails/resource/utils/injector.js in angularjs-rails-resource-1.0.0.pre.2 vs vendor/assets/javascripts/angularjs/rails/resource/utils/injector.js in angularjs-rails-resource-1.0.0.pre.3

- old
+ new

@@ -7,32 +7,49 @@ * @param dependency (string | function) The dependency to retrieve * @returns {*} The dependency */ function getDependency(dependency) { if (dependency) { - return angular.isString(dependency) ? $injector.get(dependency) : dependency + return angular.isString(dependency) ? $injector.get(dependency) : dependency; } return undefined; } /** * Looks up and instantiates an instance of the requested service. If the service is not a string then it is - * assumed to be a constuctor function. + * assumed to be a constructor function. * - * @param service (string | function) The service to instantiate + * @param {String|function|Object} service The service to instantiate * @returns {*} A new instance of the requested service */ function createService(service) { if (service) { return $injector.instantiate(getDependency(service)); } return undefined; } + /** + * Looks up and instantiates an instance of the requested service if . + * @param {String|function|Object} service The service to instantiate + * @returns {*} + */ + function getService(service) { + // strings and functions are not considered objects by angular.isObject() + if (angular.isObject(service)) { + return service; + } else if (service) { + return createService(service); + } + + return undefined; + } + return { createService: createService, + getService: getService, getDependency: getDependency - } + }; }]); }()); \ No newline at end of file