Sha256: 3dd7f54d0607e0c653e06fa1d0148f4414692f63eeb3f7a5f8c58af6eeb9f9ef
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
# Implements the core functionality of modules. This is inherited from # by instances of {Class}, so these methods are also available to # classes. class Module def name `return self.__classid__;` end def ===(obj) obj.kind_of? self end def define_method(method_id, &block) raise LocalJumpError, "no block given" unless block_given? `$rb.dm(self, #{method_id.to_s}.toString(), block)` nil end def attr_accessor(*attrs) attr_reader *attrs attr_writer *attrs end def attr_reader(*attrs) attrs.each do |a| method_id = a.to_s `$rb.dm(self, method_id, function() { var iv = this[method_id]; return iv == undefined ? nil : iv; });` end nil end def attr_writer(*attrs) attrs.each do |a| method_id = a.to_s `$rb.dm(self, method_id + '=', function(val) { return this[method_id] = val; });` end nil end def alias_method(new_name, old_name) `$rb.alias_method(self, #{new_name.to_s}, #{old_name.to_s});` self end def public_instance_methods(include_super = true) `return self.$methods;` end def instance_methods `return self.$methods;` end def ancestors `var ary = [], parent = self; while (parent) { if (parent.$f & FL_SINGLETON) { // nothing? } else { ary.push(parent); } parent = parent.$super; } return ary;` end def to_s `return self.__classid__;` end def const_set(id, value) `return rb_const_set(self, #{id.to_s}, value);` end def class_eval(str = nil, &block) if block_given? `block.call(self)` else raise "need to compile str" end end def module_eval(str = nil, &block) class_eval str, &block end def extend(mod) `rb_extend_module(self, mod)` nil end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
opal-0.3.10 | corelib/module.rb |
opal-0.3.9 | corelib/module.rb |