These are chat archives for opal/opal

Jun 2016
Mehmet Beydogan
Jun 28 2016 11:31
This message was deleted
Mehmet Beydogan
Jun 28 2016 11:39

Hi, I'm using opal-rails and upgraded from 0.8.1 to 0.9.0.

I have a global variable defined js.

On opal side, I access it by;

events = $$

problem is; when using opal rails 0.9.0 it changes the structure of objects as following;

in 0.8.1;

in 0.9.0 or any version above 0.8.1

how can i fix this issue?

Ilya Bylich
Jun 28 2016 14:23
@beydogan Could you try $$ ?
Mitch VanDuyn
Jun 28 2016 21:09
I'm pretty sure the answer is going to come back to be use eval
I'm looking at the js code generated by opal, and I see something like $scope.get('Foo') that seems to lookup component Foo. Is there a reasonable way to use this to look up 'Foo' in the current module/class lexical hierarchy?
instead of just rewriting a method?
Jamie Gaskins
Jun 28 2016 23:53

I don't think you can get lexical scope programmatically, because that's defined in the parser. If you rewrote that code instead like this:

module Foo

class Foo::Whack

module Foo::Bar

class Foo::Bar::Baz
  def self.test(s)
    const_get s.to_s
  def self.test1

Both of your test methods would fail, but your lookup method would still work.