Permalink
Browse files

[resource] allow self-nested resources

  • Loading branch information...
indutny committed Nov 15, 2011
1 parent 0690e35 commit 7919edcf05897300d2a663b6ea265120563e452a
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/resourceful/resource.js
@@ -315,7 +315,7 @@ Resource.__defineGetter__('parents', function (name) {
//
// Factory method for defining basic behaviour
//
-function relationship(factory, type, r, optons) {
+function relationship(factory, type, r, options) {
var engine = factory.engine,
rfactory, // Resource factory/constructor
rstring, // Resource string
@@ -325,6 +325,11 @@ function relationship(factory, type, r, optons) {
if (typeof(r) === 'string') {
rstring = r.toLowerCase();
rfactory = resourceful.resources[resourceful.capitalize(r)];
+
+ // We're dealing with .child('name-of-this-resource')
+ if (!rfactory && rstring === factory.resource) {
+ rfactory = factory;
+ }
} else if (typeof(r) === 'function') {
rstringc = r.resource;
rstring = rstringc.toLowerCase();

0 comments on commit 7919edc

Please sign in to comment.