Sha256: 6f03f7edb643f021e86d189c6e87c5ca88e7b38b98c0fad76c16c6cf553ee9cd

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

# BasicObject is the root object in opal. Even {Object} inherits from
# {BasicObject}. Instances of BasicObject (or subclasses of) are useful
# as they give almost a clean interface in which the absolute minimum of
# methods are defined on it. It therefore becomes useful for such
# applications as HashStructs.
class BasicObject
  def initialize
    # ...
  end

  def ==(other)
    `if (self == other) return Qtrue;
    return Qfalse;`
  end

  def equal?(other)
    self == other
  end

  def __send__(method_id, *args)
    `args.unshift(self);
    return self.$m[#{method_id.to_s}].apply(self, args);`
  end

  def instance_eval(&block)
    `block(self)` if block_given?
    self
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-0.3.2 gems/core/lib/core/basic_object.rb