Sha256: b36bb21394239df330362a45952a12a01ebbcf338e32cacc6e81a3edf4c1ff88
Contents?: true
Size: 897 Bytes
Versions: 7
Compression:
Stored size: 897 Bytes
Contents
class Proc `def._isProc = true` `def.is_lambda = false` def self.new(&block) unless block raise ArgumentError, "tried to create a Proc object without a block" end block end def call(*args, &block) %x{ if (block !== nil) { self._p = block; } var result; if (self.is_lambda) { result = self.apply(null, args); } else { result = Opal.$yieldX(self, args); } if (result === $breaker) { return $breaker.$v; } return result; } end alias [] call def to_proc self end def lambda? # This method should tell the user if the proc tricks are unavailable, # (see Proc#lambda? on ruby docs to find out more). `!!self.is_lambda` end # FIXME: this should support the various splats and optional arguments def arity `self.length` end end
Version data entries
7 entries across 7 versions & 1 rubygems