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


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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


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

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner


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

def owner
  @owner
end

Instance Method Details

#arityObject


56
57
58
# File 'opal/opal/corelib/method.rb', line 56

def arity
  @method.arity
end

#bind(object) ⇒ Object


64
65
66
67
68
69
70
# File 'opal/opal/corelib/method.rb', line 64

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


72
73
74
# File 'opal/opal/corelib/method.rb', line 72

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

#parametersObject


60
61
62
# File 'opal/opal/corelib/method.rb', line 60

def parameters
  `#{@method}.$$parameters`
end