marmelab/gremlins.js — pull request #64 by fzaninotto (2014-04-14 21:40:45+00:00)
Title: [RFR] Refactor service injection to mogwais and gremlins

* Gremlins and mogwais no longer have default logger and randomizer
* When a mogwai or a gremlin absolutely needs a service, and this service isn't present when it executes, it throws an appropriate exception
* The horde only injects logger and randomizer if not present (fixes #62)
* Anonymous function get a name everywhere as is simplifies debugging

The price to pay to fix #62 is that bundled gremlins are no longer self-sufficient.

Before:

```js
// standalone usage
var clicker = gremlins.species.clicker();
clicker(); // works
clicker.randomizer({ natural: function() { return 1; }); // works

// horde usage
var clicker = gremlins.species.clicker();
clicker.randomizer({ natural: function() { return 1; }); // does not work, overridden by horde!
horde.gremlin(clicker);
```

After:

```js
// standalone usage
var clicker = gremlins.species.clicker();
clicker(); // doesn't work - exception thorwn requiring randomizer
clicker.randomizer(new Chance());
clicker(); // works
clicker.randomizer({ natural: function() { return 1; }); // works

// horde usage
var clicker = gremlins.species.clicker();
clicker.randomizer({ natural: function() { return 1; }); // works, not overridden by horde
horde.gremlin(clicker);
```

However, as gremlins are used inside a horde 99% of the time, that's no big a deal.