{"action":"created","issue":{"url":"https://api.github.com/repos/andrewplummer/Sugar/issues/559","repository_url":"https://api.github.com/repos/andrewplummer/Sugar","labels_url":"https://api.github.com/repos/andrewplummer/Sugar/issues/559/labels{/name}","comments_url":"https://api.github.com/repos/andrewplummer/Sugar/issues/559/comments","events_url":"https://api.github.com/repos/andrewplummer/Sugar/issues/559/events","html_url":"https://github.com/andrewplummer/Sugar/issues/559","id":179382226,"number":559,"title":"How do I create the following chainable functions?","user":{"login":"holgersindbaek","id":698979,"avatar_url":"https://avatars.githubusercontent.com/u/698979?v=3","gravatar_id":"","url":"https://api.github.com/users/holgersindbaek","html_url":"https://github.com/holgersindbaek","followers_url":"https://api.github.com/users/holgersindbaek/followers","following_url":"https://api.github.com/users/holgersindbaek/following{/other_user}","gists_url":"https://api.github.com/users/holgersindbaek/gists{/gist_id}","starred_url":"https://api.github.com/users/holgersindbaek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holgersindbaek/subscriptions","organizations_url":"https://api.github.com/users/holgersindbaek/orgs","repos_url":"https://api.github.com/users/holgersindbaek/repos","events_url":"https://api.github.com/users/holgersindbaek/events{/privacy}","received_events_url":"https://api.github.com/users/holgersindbaek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-27T02:21:59Z","updated_at":"2016-09-27T03:02:04Z","closed_at":null,"body":"I would like to be able to have a more Ruby like syntax, so being able to do the following on the \"Object\" would be great:\r\n\r\n    Object(\"one\").isEqual(\"two\") // false\r\n    Object(\"one\").isNotEqual(\"two\") // true\r\n    Object(false).isTrue() // false\r\n    Object(false).isFalse() // true\r\n\r\nIs it possible to create these chainable functions? How would I do that in Sugar?"},"comment":{"url":"https://api.github.com/repos/andrewplummer/Sugar/issues/comments/249754462","html_url":"https://github.com/andrewplummer/Sugar/issues/559#issuecomment-249754462","issue_url":"https://api.github.com/repos/andrewplummer/Sugar/issues/559","id":249754462,"user":{"login":"andrewplummer","id":74646,"avatar_url":"https://avatars.githubusercontent.com/u/74646?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewplummer","html_url":"https://github.com/andrewplummer","followers_url":"https://api.github.com/users/andrewplummer/followers","following_url":"https://api.github.com/users/andrewplummer/following{/other_user}","gists_url":"https://api.github.com/users/andrewplummer/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewplummer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewplummer/subscriptions","organizations_url":"https://api.github.com/users/andrewplummer/orgs","repos_url":"https://api.github.com/users/andrewplummer/repos","events_url":"https://api.github.com/users/andrewplummer/events{/privacy}","received_events_url":"https://api.github.com/users/andrewplummer/received_events","type":"User","site_admin":false},"created_at":"2016-09-27T03:02:04Z","updated_at":"2016-09-27T03:02:04Z","body":"You seem to have it set up correctly. When you run `extend` it will not extend `Object.prototype` by default. You can force it to do this by running:\r\n\r\n```javascript\r\nSugar.extend({\r\n  objectPrototype: true\r\n});\r\n```\r\n\r\nHowever this is highly discouraged as it can have lots of unintended consequences. Also, even if you do this your example still will not work as `undefined` is not an actual object with a prototype and so cannot have it's methods mapped.\r\n\r\nThe idea behind chainables is that they are always used through the Sugar global, so `Object(undefined)` isn't running through Sugar in any way (you may already know this). Calling `extend` will only map *methods* onto natives and their prototypes, nothing else.\r\n\r\nIf using `Sugar.Object` (or ideally `new Sugar.Object`) is too long you can map it to something shorter like `$O`, etc.\r\n\r\nAs for the result, this is intended behavior, so the result can be accessed through the `.raw` property. The property is intentionally short so it shouldn't add much overhead to your code. Additionally `valueOf` is mapped to this property so although you can't do truthy/falsy tests, if you use `==`, it will unwrap and you won't have to use `.raw`.\r\n\r\n"}}
{"actor":{"display_login":"andrewplummer"}}