Sha256: 00b262bcf80b7a05de21939e713a8b6f3c35e8208d32e79b38051dfb80e4c24f

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

class BasicObject
  def initialize(*)
  end

  def ==(other)
    `#{self} === other`
  end

  def __send__(symbol, *args, &block)
    %x{
      var meth = #{self}.$m[symbol];

      if (!meth) {
        return #{ method_missing symbol };
      }

      return meth.apply(null, [#{self}].concat(args));
    }
  end

  alias send __send__

  alias eql? ==
  alias equal? ==

  def instance_eval(string, &block)
    %x{
      if (block === nil) {
        no_block_given();
      }

      return block(#{self});
    }
  end

  def instance_exec(*args, &block)
    %x{
      if (block === nil) {
        no_block_given();
      }

      return block.apply(this, args);
    }
  end

  def method_missing(symbol, *args)
    raise NoMethodError, "undefined method `#{symbol}` for #{inspect}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-0.3.21 core/basic_object.rb