It breaks initial logic, as you said (a && b && c) is not equals (a && (b
|| c)). This fact should be enough to not doing this change (at least
without detailed explanation why). Especially when you do not understand
purpose of that code. Anyways, I can explain what this code does: when you
pass mongodb ObjectID instance it also have and id, and it's id looks like
unreadable binary string. We have to check that `arg.constructor.name` is
not 'ObjectID' and not use id when it is. I thought this logic is so
obvious, that it doesn't even requires commenting. If it doesn't look
obvious for you, you can check git log for that line and it will give you
reason of this logic, often with link to some closed issue. Finally, it may
be useful to add comment on this line, or, even better refactor it (without
breaking logic!) to make it more clear and easier to read. But would be
great to write tests before to demonstrate expected behavior of that line.


On Thu, Jan 17, 2013 at 3:52 PM, Artem Shoobovych
<notifications@github.com>wrote:

> In lib/railway_routes.js:
>
> > @@ -173,9 +173,9 @@ Map.prototype.addPath = function (templatePath, action, helperName) {
> >          for (var i = 0; i < paramsLength; i += 1) {
> >              value = null;
> >              arg = arguments[i];
> > -            if (arg && typeof arg.to_param == 'function') {
> > -                value = arg.to_param();
> > -            } else if (typeof arg === 'object' && arg.id && arg.constructor.name !== 'ObjectID') {
> > +            if (arg && typeof(arg.to_param) == 'function') {
> > +                //value = arg.to_param();
> > +            } else if (typeof(arg) === 'object' && (arg.id || arg.constructor.name !== 'ObjectID')) {
>
> Could you be more specific, what does it breaks?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/1602/railway-routes/pull/13/files#r2678032>.
>
>



-- 
Thanks,
Anatoliy Chakkaev