-
Notifications
You must be signed in to change notification settings - Fork 4
/
pimple.min.js
8 lines (8 loc) · 1.6 KB
/
pimple.min.js
1
2
3
4
5
6
7
8
/*
Pimple dependency injection container
@copyright 2011 M.PARAISO <[email protected]>
@license LGPL
@version 0.0.3
*/
!function(){"use strict";var self=this;var _isFunction=function(object){return object instanceof Function};var reservedProperties=["get","set","factory","raw","protect","share","toString","constructor"];this.Pimple=function(definitions){if(!(this instanceof self.Pimple)){return new self.Pimple(definitions)}this._definitions={};for(var key in definitions){if(definitions.hasOwnProperty(key)){this.set(key,definitions[key])}}};this.Pimple.prototype={get:function(key){if(this._definitions[key]===undefined)return;if(_isFunction(this._definitions[key])){return this._definitions[key].call(this,this)}return this._definitions[key]},set:function(key,definition){this._definitions[key]=definition;if(reservedProperties.indexOf(key)===-1){Object.defineProperty(this,key,{get:function(){return this.get(key)},configurable:true,enumerable:true})}return this},raw:function(key){return this._definitions[key]},share:function(definition){var cached,self=this;return function(){if(cached===undefined){cached=definition.call(self,self)}return cached}},protect:function(definition,context){context=context||this;return function(){return definition.bind(context)}},extend:function(key,definition){return definition.bind(this,this.get(key),this)},register:function(definitionProvider){return definitionProvider(this)}};if(this.define instanceof Function){var self=this;this.define("pimple",[],function(){return self.Pimple})}if(module&&module.exports){module.exports=this.Pimple}}.apply(this);
//# sourceMappingURL=pimple.js.map