{"action":"created","issue":{"url":"https://api.github.com/repos/opal/opal/issues/1244","labels_url":"https://api.github.com/repos/opal/opal/issues/1244/labels{/name}","comments_url":"https://api.github.com/repos/opal/opal/issues/1244/comments","events_url":"https://api.github.com/repos/opal/opal/issues/1244/events","html_url":"https://github.com/opal/opal/issues/1244","id":121892258,"number":1244,"title":"Hash#to_n doesn't handle JS values","user":{"login":"jgaskins","id":108205,"avatar_url":"https://avatars.githubusercontent.com/u/108205?v=3","gravatar_id":"","url":"https://api.github.com/users/jgaskins","html_url":"https://github.com/jgaskins","followers_url":"https://api.github.com/users/jgaskins/followers","following_url":"https://api.github.com/users/jgaskins/following{/other_user}","gists_url":"https://api.github.com/users/jgaskins/gists{/gist_id}","starred_url":"https://api.github.com/users/jgaskins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgaskins/subscriptions","organizations_url":"https://api.github.com/users/jgaskins/orgs","repos_url":"https://api.github.com/users/jgaskins/repos","events_url":"https://api.github.com/users/jgaskins/events{/privacy}","received_events_url":"https://api.github.com/users/jgaskins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-13T01:56:34Z","updated_at":"2015-12-15T13:34:38Z","closed_at":null,"body":"I tried porting part of the [`asciify-me` Inesita app](https://github.com/inesita-rb/asciify-me) to Clearwater. One of the things I'm trying to do is:\r\n\r\n```ruby\r\nclass VideoOutput\r\n  # ...\r\n  def render\r\n    video(src: webcam.stream)\r\n  end\r\nend\r\n```\r\n\r\nBut `webcam.stream` is not a Ruby object; it's an instance of a JavaScript `MediaStream`. When that attributes hash gets `to_n` called on it, it raises an exception because JS objects don't respond to `respond_to?`.\r\n\r\nIs there a way we can detect whether the value is a Ruby object and leave it alone if not? I thought at one point there was an `$$is_ruby` or `$$is_opal` property on the prototype of all Ruby `Object` descendants, but I might be remembering a conversation about it and not actual code. :-)"},"comment":{"url":"https://api.github.com/repos/opal/opal/issues/comments/164766180","html_url":"https://github.com/opal/opal/issues/1244#issuecomment-164766180","issue_url":"https://api.github.com/repos/opal/opal/issues/1244","id":164766180,"user":{"login":"iliabylich","id":1265492,"avatar_url":"https://avatars.githubusercontent.com/u/1265492?v=3","gravatar_id":"","url":"https://api.github.com/users/iliabylich","html_url":"https://github.com/iliabylich","followers_url":"https://api.github.com/users/iliabylich/followers","following_url":"https://api.github.com/users/iliabylich/following{/other_user}","gists_url":"https://api.github.com/users/iliabylich/gists{/gist_id}","starred_url":"https://api.github.com/users/iliabylich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iliabylich/subscriptions","organizations_url":"https://api.github.com/users/iliabylich/orgs","repos_url":"https://api.github.com/users/iliabylich/repos","events_url":"https://api.github.com/users/iliabylich/events{/privacy}","received_events_url":"https://api.github.com/users/iliabylich/received_events","type":"User","site_admin":false},"created_at":"2015-12-15T13:34:38Z","updated_at":"2015-12-15T13:34:38Z","body":"@jgaskins Yeah, all recursive structures have this issue, for example `Array`:\r\n``` ruby\r\na = [`{}`]\r\na.to_n\r\n```\r\n[This place](https://github.com/opal/opal/blob/master/stdlib/native.rb#L495) contains the bug. I suppose it should be something like\r\n``` ruby\r\n%x{\r\n  result.push(#{Native.try_convert(obj)});\r\n}\r\n```"}}