Class: UnboundMethod

Inherits:
Object show all
Defined in:
opal/opal/corelib/method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, method, name) ⇒ UnboundMethod

Returns a new instance of UnboundMethod



46
47
48
49
50
# File 'opal/opal/corelib/method.rb', line 46

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name



44
45
46
# File 'opal/opal/corelib/method.rb', line 44

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner



44
45
46
# File 'opal/opal/corelib/method.rb', line 44

def owner
  @owner
end

Instance Method Details

#arityObject



52
53
54
# File 'opal/opal/corelib/method.rb', line 52

def arity
  @method.arity
end

#bind(object) ⇒ Object



56
57
58
59
60
61
62
# File 'opal/opal/corelib/method.rb', line 56

def bind(object)
  # TODO: re-enable when Module#< is fixed
  # unless object.class <= @owner
  #   raise TypeError, "can't bind singleton method to a different class"
  # end
  Method.new(object, @method, @name)
end

#inspectObject



64
65
66
# File 'opal/opal/corelib/method.rb', line 64

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