Sha256: 398a0c21f93a5c056aa9dde3da8108df36f0d0a81dfb29ec37b95fe1af2f8480

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

class Class
  def self.new(sup = Object, &block)
    %x{
      var klass             = boot_class(sup);
          klass.__classid__ = "AnonClass";

      make_metaclass(klass, sup.$klass);

      #{sup.inherited `klass`};

      return block !== nil ? block.call(klass, null) : klass;
    }
  end

  def allocate
    `new this.$allocator()`
  end

  def new(*args, &block)
    obj = allocate()
    obj.initialize *args, &block
    obj
  end

  def inherited(cls)
  end

  def superclass
    %x{
      var sup = this.$s;

      if (!sup) {
        if (this === RubyObject) {
          return nil;
        }

        raise(RubyRuntimeError, 'uninitialized class');
      }

      return sup;
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-0.3.15 runtime/corelib/class.rb