-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a method to add 'plugins' to hoodie object. Plugins can be passed as a function (a callback that will recieve hoodie as a parameter) or an object (the key will be the method name, and the value is the function). Plugin calls can be chained to add multiple plugins. See README.md for examples. closes #2
- Loading branch information
1 parent
3545989
commit a12d793
Showing
2 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = function pluginMethod (plugin) { | ||
var self = this | ||
|
||
if (typeof plugin === 'function') { | ||
plugin(self) | ||
} | ||
|
||
if (typeof plugin === 'object') { | ||
Object.keys(plugin).forEach(function (key) { | ||
self[key] = plugin[key] | ||
}) | ||
} | ||
|
||
return self | ||
} |