function Bottle(name) { if (!(this instanceof Bottle)) { return Bottle.pop(name); } this.id = id++; this.decorators = {}; this.middlewares = {}; this.nested = {}; this.providerMap = {}; this.originalProviders = {}; this.deferred = []; this.container = { $decorator : decorator.bind(this), $register : register.bind(this), $list : list.bind(this) }; }
n/a
function Bottle(name) { if (!(this instanceof Bottle)) { return Bottle.pop(name); } this.id = id++; this.decorators = {}; this.middlewares = {}; this.nested = {}; this.providerMap = {}; this.originalProviders = {}; this.deferred = []; this.container = { $decorator : decorator.bind(this), $register : register.bind(this), $list : list.bind(this) }; }
n/a
function clear(name) { if (typeof name === 'string') { delete bottles[name]; } else { bottles = {}; } }
n/a
function list(container) { return Object.keys(container || this.container || {}).filter(byMethod); }
...
In general, this function should only be called in situations where you intend to reset the bottle instance with new providers,
decorators, etc. such as test setup.
Param | Type | Details
:--------------------------|:-----------|:--------
**name**<br />*(optional)* | *String* | The name of the bottle. If passed, bottle will remove the internal instance,
if such a bottle was created using `Bottle.pop`. If not passed, all named internal instances will be cleared.
#### list(container)
#### prototype.list()
#### prototype.container.$list()
Used to list the names of all registered constants, values, and services on the container. Must pass a container to the global
static version `Bottle.list(bottle.container)`. The instance and container versions return the services that are registered within
.
Returns an array of strings.
Param | Type | Details
...
function pop(name) { var instance; if (typeof name === 'string') { instance = bottles[name]; if (!instance) { bottles[name] = instance = new Bottle(); instance.constant('BOTTLE_NAME', name); } return instance; } return new Bottle(); }
...
## API
### Bottle
#### pop(name)
Used to get an instance of bottle. If a name is passed, bottle will return the same instance. Calling the Bottle constructor as
a function will call and return return `Bottle.pop`, so `Bottle.pop('Soda') ===
Bottle('Soda')`
Param | Type | Details
:--------------------------|:-----------|:--------
**name**<br />*(optional)* | *String* | The name of the bottle. If passed, bottle will store the instance internally
and return the same instance if `Bottle.pop` is subsequently called with the same name.
#### clear(name)
...
toString = function () { return text; }
n/a
function clear(name) { if (typeof name === 'string') { delete bottles[name]; } else { bottles = {}; } }
n/a
function list(container) { return Object.keys(container || this.container || {}).filter(byMethod); }
...
In general, this function should only be called in situations where you intend to reset the bottle instance with new providers,
decorators, etc. such as test setup.
Param | Type | Details
:--------------------------|:-----------|:--------
**name**<br />*(optional)* | *String* | The name of the bottle. If passed, bottle will remove the internal instance,
if such a bottle was created using `Bottle.pop`. If not passed, all named internal instances will be cleared.
#### list(container)
#### prototype.list()
#### prototype.container.$list()
Used to list the names of all registered constants, values, and services on the container. Must pass a container to the global
static version `Bottle.list(bottle.container)`. The instance and container versions return the services that are registered within
.
Returns an array of strings.
Param | Type | Details
...
function pop(name) { var instance; if (typeof name === 'string') { instance = bottles[name]; if (!instance) { bottles[name] = instance = new Bottle(); instance.constant('BOTTLE_NAME', name); } return instance; } return new Bottle(); }
...
## API
### Bottle
#### pop(name)
Used to get an instance of bottle. If a name is passed, bottle will return the same instance. Calling the Bottle constructor as
a function will call and return return `Bottle.pop`, so `Bottle.pop('Soda') ===
Bottle('Soda')`
Param | Type | Details
:--------------------------|:-----------|:--------
**name**<br />*(optional)* | *String* | The name of the bottle. If passed, bottle will store the instance internally
and return the same instance if `Bottle.pop` is subsequently called with the same name.
#### clear(name)
...
function toString() { [native code] }
n/a