Sha256: 020501111e6c8b6f0f2412a0887e36386ffba0b09aee6dfe155038652094e85d

Contents?: true

Size: 415 Bytes

Versions: 5

Compression:

Stored size: 415 Bytes

Contents

module Native
  def initialize(native)
    %x{
      if (#{native} == null) {
        #{ raise "null or undefined passed to Native" };
      }
    }

    @native = native
  end

  def method_missing(symbol, *args, &block)
    native = @native

    %x{
      var func;

      if (func = #{native}[#{symbol}]) {
        return func.call(#{native});
      }
    }

    nil
  end

  def to_native
    @native
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-0.3.42 opal/opal/native.rb
opal-0.3.41 opal/opal/native.rb
opal-0.3.40 lib/assets/javascripts/opal/native.rb
opal-0.3.39 lib/assets/javascripts/opal/native.rb
opal-0.3.38 lib/assets/javascripts/opal/native.rb