{"action":"created","issue":{"url":"https://api.github.com/repos/dfilatov/inherit/issues/20","labels_url":"https://api.github.com/repos/dfilatov/inherit/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/dfilatov/inherit/issues/20/comments","events_url":"https://api.github.com/repos/dfilatov/inherit/issues/20/events","html_url":"https://github.com/dfilatov/inherit/issues/20","id":94030273,"number":20,"title":"Override order is reversed when providing functions instead of Objects","user":{"login":"kafoso","id":3169691,"avatar_url":"https://avatars.githubusercontent.com/u/3169691?v=3","gravatar_id":"","url":"https://api.github.com/users/kafoso","html_url":"https://github.com/kafoso","followers_url":"https://api.github.com/users/kafoso/followers","following_url":"https://api.github.com/users/kafoso/following{/other_user}","gists_url":"https://api.github.com/users/kafoso/gists{/gist_id}","starred_url":"https://api.github.com/users/kafoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kafoso/subscriptions","organizations_url":"https://api.github.com/users/kafoso/orgs","repos_url":"https://api.github.com/users/kafoso/repos","events_url":"https://api.github.com/users/kafoso/events{/privacy}","received_events_url":"https://api.github.com/users/kafoso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-09T12:07:26Z","updated_at":"2015-07-09T12:30:27Z","closed_at":null,"body":"In `test.js`, `exports.testOverride` verifies that the \"youngest\" Object (or \"class\") overrides the same-name function of its parent (or \"base\"). This test of course works.\r\n\r\nHowever, if the `prop` argument is a function, the override order is reversed. See example below.\r\n\r\n```javascript\r\nexports.testOverrideOfFunctions = function(test) {\r\n    test.expect(2);\r\n    var A = inherit(function(){\r\n      this.method = function() {\r\n          return 'A';\r\n      };\r\n    });\r\n    var B = inherit(A, function(){\r\n      this.method = function() {\r\n          return 'B';\r\n      };\r\n    });\r\n\r\n    test.equal(new A().method(), 'A');\r\n    test.equal(new B().method(), 'B');\r\n    test.done();\r\n};\r\n```\r\n\r\nThe above test fails. See output below.\r\n\r\n```shell\r\n✖ testOverrideOfFunctions\r\n\r\nAssertionError: 'B' == 'A'\r\n    at Object.equal (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)\r\n    at Object.exports.testOverrideOfFunctions (/home/kafoso/git/inherit/test/test.js:142:10)\r\n    at Object.<anonymous> (/usr/local/lib/node_modules/nodeunit/lib/core.js:236:16)\r\n    at /usr/local/lib/node_modules/nodeunit/lib/core.js:236:16\r\n    at Object.exports.runTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:70:9)\r\n    at /usr/local/lib/node_modules/nodeunit/lib/core.js:118:25\r\n    at /usr/local/lib/node_modules/nodeunit/deps/async.js:513:13\r\n    at iterate (/usr/local/lib/node_modules/nodeunit/deps/async.js:123:13)\r\n    at /usr/local/lib/node_modules/nodeunit/deps/async.js:134:25\r\n    at /usr/local/lib/node_modules/nodeunit/deps/async.js:515:17\r\n```\r\n\r\nNaturally, the [`prop` argument should be an Object per your documentation](https://github.com/dfilatov/inherit#creating-a-base-class). However, it would be a nice addition."},"comment":{"url":"https://api.github.com/repos/dfilatov/inherit/issues/comments/119944571","html_url":"https://github.com/dfilatov/inherit/issues/20#issuecomment-119944571","issue_url":"https://api.github.com/repos/dfilatov/inherit/issues/20","id":119944571,"user":{"login":"kafoso","id":3169691,"avatar_url":"https://avatars.githubusercontent.com/u/3169691?v=3","gravatar_id":"","url":"https://api.github.com/users/kafoso","html_url":"https://github.com/kafoso","followers_url":"https://api.github.com/users/kafoso/followers","following_url":"https://api.github.com/users/kafoso/following{/other_user}","gists_url":"https://api.github.com/users/kafoso/gists{/gist_id}","starred_url":"https://api.github.com/users/kafoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kafoso/subscriptions","organizations_url":"https://api.github.com/users/kafoso/orgs","repos_url":"https://api.github.com/users/kafoso/repos","events_url":"https://api.github.com/users/kafoso/events{/privacy}","received_events_url":"https://api.github.com/users/kafoso/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T12:30:27Z","updated_at":"2015-07-09T12:30:27Z","body":"@dfilatov \r\nTo allow for private variables inside the functions. Example:\r\n\r\n```javascript\r\nexports.testInheritedFunctionsWithPrivateVariables = function(test) {\r\n    test.expect(2);\r\n    var A = inherit(function(){\r\n      var _privateVariable = 1;\r\n      this.method = function() {\r\n          return _privateVariable+2;\r\n      };\r\n    });\r\n    var B = inherit(A, function(){\r\n      var _privateVariable = 9;\r\n      this.method = function() {\r\n          return _privateVariable+2;\r\n      };\r\n    });\r\n\r\n    test.equal(new A().method(), 3); // Works\r\n    test.equal(new B().method(), 11); // Throws up\r\n    test.done();\r\n};\r\n```\r\n\r\nOutput:\r\n\r\n```shell\r\n✖ testInheritedFunctionsWithPrivateVariables\r\n\r\nAssertionError: 3 == 11\r\n    at Object.equal (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)\r\n    at Object.exports.testInheritedFunctionsWithPrivateVariables (/home/kafoso/git/inherit/test/test.js:145:10)\r\n    at Object.<anonymous> (/usr/local/lib/node_modules/nodeunit/lib/core.js:236:16)\r\n    at /usr/local/lib/node_modules/nodeunit/lib/core.js:236:16\r\n    at Object.exports.runTest (/usr/local/lib/node_modules/nodeunit/lib/core.js:70:9)\r\n    at /usr/local/lib/node_modules/nodeunit/lib/core.js:118:25\r\n    at /usr/local/lib/node_modules/nodeunit/deps/async.js:513:13\r\n    at iterate (/usr/local/lib/node_modules/nodeunit/deps/async.js:123:13)\r\n    at /usr/local/lib/node_modules/nodeunit/deps/async.js:134:25\r\n    at /usr/local/lib/node_modules/nodeunit/deps/async.js:515:17\r\n```"}}