Sha256: 08ddc5f24c5c06bd6b2e664941f75c6d405ccb08c1eefb24fd8d246f65be44b8

Contents?: true

Size: 867 Bytes

Versions: 13

Compression:

Stored size: 867 Bytes

Contents

class Method
  attr_reader :owner, :receiver, :name

  def initialize(receiver, method, name)
    @receiver = receiver
    @owner    = receiver.class
    @name     = name
    @method   = method
  end

  def arity
    @method.arity
  end

  def call(*args, &block)
    %x{
      #@method.$$p = block;

      return #@method.apply(#@receiver, args);
    }
  end

  alias [] call

  def unbind
    UnboundMethod.new(@owner, @method, @name)
  end

  def to_proc
    @method
  end

  def inspect
    "#<Method: #{@obj.class}##@name}>"
  end
end

class UnboundMethod
  attr_reader :owner, :name

  def initialize(owner, method, name)
    @owner  = owner
    @method = method
    @name   = name
  end

  def arity
    @method.arity
  end

  def bind(object)
    Method.new(object, @method, @name)
  end

  def inspect
    "#<UnboundMethod: #{@owner.name}##@name>"
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
opal-0.8.1 opal/corelib/method.rb
opal-0.8.1.rc1 opal/corelib/method.rb
opal-0.8.0 opal/corelib/method.rb
opal-0.8.0.rc3 opal/corelib/method.rb
opal-0.8.0.rc2 opal/corelib/method.rb
opal-0.8.0.rc1 opal/corelib/method.rb
opal-0.8.0.beta1 opal/corelib/method.rb
opal-0.7.2 opal/corelib/method.rb
opal-0.7.1 opal/corelib/method.rb
opal-0.7.0 opal/corelib/method.rb
opal-0.7.0.rc1 opal/corelib/method.rb
opal-0.7.0.beta3 opal/corelib/method.rb
opal-0.7.0.beta2 opal/corelib/method.rb