Skip to content

Commit

Permalink
move extend methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Aug 1, 2015
1 parent 8b4cd1e commit 069b1cf
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 119 deletions.
39 changes: 19 additions & 20 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,8 @@ function Base(options) {
if (typeof this.options.mixins === 'object') {
this.visit('mixin', this.options.mixins);
}
// this.cache = this.cache || {};
}

/**
*
* Expose `extend`, static method for allowing other classes to inherit
* from the `Base` class (and receive all of Base's prototype methods).
*
* ```js
* function MyClass(options) {...}
* Base.extend(MyClass);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Base`
* @return {undefined}
* @api public
*/

Base.extend = function (obj) {
util.inherits(obj, Base);
};

/**
* `Base` prototype methods
*/
Expand Down Expand Up @@ -391,6 +371,25 @@ Base.prototype = Emitter({
}
});

/**
*
* Expose `extend`, static method for allowing other classes to inherit
* from the `Base` class (and receive all of Base's prototype methods).
*
* ```js
* function MyClass(options) {...}
* Base.extend(MyClass);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Base`
* @return {undefined}
* @api public
*/

Base.extend = function (obj) {
util.inherits(obj, Base);
};

/**
* Expose `Base`
*/
Expand Down
38 changes: 19 additions & 19 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,6 @@ function Collection(options) {

Base.extend(Collection);

/**
*
* Expose `extend`, static method for allowing other classes to inherit
* from the `Collection` class (and receive all of Collection's prototype methods).
*
* ```js
* function MyCustomCollection(options) {...}
* Collection.extend(MyCustomCollection);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Collection`
* @return {undefined}
* @api public
*/

Collection.extend = function(obj) {
util.inherits(obj, Collection);
};

/**
* `Collection` prototype methods
*/
Expand Down Expand Up @@ -216,6 +197,25 @@ utils.delegate(Collection.prototype, {
}
});

/**
*
* Expose `extend`, static method for allowing other classes to inherit
* from the `Collection` class (and receive all of Collection's prototype methods).
*
* ```js
* function MyCustomCollection(options) {...}
* Collection.extend(MyCustomCollection);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Collection`
* @return {undefined}
* @api public
*/

Collection.extend = function(obj) {
util.inherits(obj, Collection);
};

/**
* Expose `Collection`
*/
Expand Down
36 changes: 18 additions & 18 deletions lib/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@ function File(file, options) {

Item.extend(File);

/**
* Expose `extend`, to allow other classes to inherit
* from the `File` class.
*
* ```js
* function MyCustomFile(options) {...}
* File.extend(MyCustomFile);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `File`
* @return {undefined}
* @api public
*/

File.extend = function (Ctor) {
util.inherits(Ctor, File);
};

/**
* `File` prototype methods
*/
Expand Down Expand Up @@ -154,6 +136,24 @@ Object.defineProperty(File.prototype, 'layout', {
}
});

/**
* Expose `extend`, to allow other classes to inherit
* from the `File` class.
*
* ```js
* function MyFile(options) {...}
* File.extend(MyFile);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `File`
* @return {undefined}
* @api public
*/

File.extend = function (Ctor) {
util.inherits(Ctor, File);
};

/**
* Expose `File`
*/
Expand Down
38 changes: 19 additions & 19 deletions lib/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,6 @@ function Item(item, options) {

Base.extend(Item);

/**
*
* Expose `extend`, static method for allowing other classes to inherit
* from the `Item` class (and receive all of Item's prototype methods).
*
* ```js
* function MyCustomItem(options) {...}
* Item.extend(MyCustomItem);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Item`
* @return {undefined}
* @api public
*/

Item.extend = function(obj) {
util.inherits(obj, Item);
};

/**
* `Item` prototype methods
*/
Expand Down Expand Up @@ -167,6 +148,25 @@ utils.delegate(Item.prototype, {
}
});

/**
*
* Expose `extend`, static method for allowing other classes to inherit
* from the `Item` class (and receive all of Item's prototype methods).
*
* ```js
* function MyItem(options) {...}
* Item.extend(MyItem);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Item`
* @return {undefined}
* @api public
*/

Item.extend = function(obj) {
util.inherits(obj, Item);
};

/**
* Expose `Item`
*/
Expand Down
36 changes: 18 additions & 18 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,6 @@ function List(options) {

Base.extend(List);

/**
* Expose `extend`, to allow other classes to inherit
* from the `List` class.
*
* ```js
* function MyCustomList(options) {...}
* List.extend(MyCustomList);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `List`
* @return {undefined}
* @api public
*/

List.extend = function(Ctor) {
util.inherits(Ctor, List);
};

/**
* `List` prototype methods
*/
Expand Down Expand Up @@ -178,6 +160,24 @@ utils.delegate(List.prototype, {
},
});

/**
* Expose `extend`, to allow other classes to inherit
* from the `List` class.
*
* ```js
* function MyList(options) {...}
* List.extend(MyList);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `List`
* @return {undefined}
* @api public
*/

List.extend = function(Ctor) {
util.inherits(Ctor, List);
};

/**
* Expose `List`
*/
Expand Down
14 changes: 7 additions & 7 deletions lib/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ module.exports = function (app) {
* that matches the given glob pattern.
*
* ```js
* var pages = template.matchView('pages', 'home.*');
* var pages = app.matchView('pages', 'home.*');
* //=> {'home.hbs': { ... }, ...}
*
* var posts = template.matchView('posts', '2010-*');
* var posts = app.matchView('posts', '2010-*');
* //=> {'2015-10-10.md': { ... }, ...}
* ```
*
Expand All @@ -37,10 +37,10 @@ module.exports = function (app) {
* that match the given glob pattern.
*
* ```js
* var pages = template.matchViews('pages', 'home.*');
* var pages = app.matchViews('pages', 'home.*');
* //=> {'home.hbs': { ... }, ...}
*
* var posts = template.matchViews('posts', '2010-*');
* var posts = app.matchViews('posts', '2010-*');
* //=> {'2015-10-10.md': { ... }, ...}
* ```
*
Expand All @@ -60,7 +60,7 @@ module.exports = function (app) {
* Get a specific template from the specified collection.
*
* ```js
* template.getView('pages', 'a.hbs', function(fp) {
* app.getView('pages', 'a.hbs', function(fp) {
* return path.basename(fp);
* });
* ```
Expand Down Expand Up @@ -97,10 +97,10 @@ module.exports = function (app) {
* Get a view `collection` by its singular or plural name.
*
* ```js
* var pages = template.getViews('pages');
* var pages = app.getViews('pages');
* //=> { pages: {'home.hbs': { ... }}
*
* var posts = template.getViews('posts');
* var posts = app.getViews('posts');
* //=> { posts: {'2015-10-10.md': { ... }}
* ```
*
Expand Down
36 changes: 18 additions & 18 deletions lib/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@ function Views(options) {

Collection.extend(Views);

/**
* Expose `extend`, to allow other classes to inherit
* from the `Views` class.
*
* ```js
* function MyCustomViews(options) {...}
* Views.extend(MyCustomViews);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Views`
* @return {undefined}
* @api public
*/

Views.extend = function (obj) {
util.inherits(obj, Views);
};

/**
* `Views` prototype methods
*/
Expand Down Expand Up @@ -231,6 +213,24 @@ utils.delegate(Views.prototype, {
}
});

/**
* Expose `extend`, to allow other classes to inherit
* from the `Views` class.
*
* ```js
* function MyViews(options) {...}
* Views.extend(MyViews);
* ```
*
* @param {Object} `Ctor` Constructor function to extend with `Views`
* @return {undefined}
* @api public
*/

Views.extend = function (obj) {
util.inherits(obj, Views);
};

/**
* Expose `Views`
*/
Expand Down

0 comments on commit 069b1cf

Please # to comment.