Class: UnboundMethod
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #arity ⇒ Object
- #bind(object) ⇒ Object
- #bind_call(object, *args, &block) ⇒ Object
- #comments ⇒ Object
-
#initialize(source, owner, method, name) ⇒ UnboundMethod
constructor
A new instance of UnboundMethod.
- #inspect ⇒ Object
- #parameters ⇒ Object
- #source_location ⇒ Object
Constructor Details
#initialize(source, owner, method, name) ⇒ UnboundMethod
Returns a new instance of UnboundMethod.
73 74 75 76 77 78 |
# File 'opal/opal/corelib/method.rb', line 73 def initialize(source, owner, method, name) @source = source @owner = owner @method = method @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
71 72 73 |
# File 'opal/opal/corelib/method.rb', line 71 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
71 72 73 |
# File 'opal/opal/corelib/method.rb', line 71 def owner @owner end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
71 72 73 |
# File 'opal/opal/corelib/method.rb', line 71 def source @source end |
Instance Method Details
#arity ⇒ Object
80 81 82 |
# File 'opal/opal/corelib/method.rb', line 80 def arity @method.arity end |
#bind(object) ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'opal/opal/corelib/method.rb', line 96 def bind(object) %x{ if (#{@owner}.$$is_module || Opal.is_a(#{object}, #{@owner})) { return #{::Method.new(object, @owner, @method, @name)}; } else { #{::Kernel.raise ::TypeError, "can't bind singleton method to a different class (expected #{object}.kind_of?(#{@owner} to be true)"}; } } end |
#bind_call(object, *args, &block) ⇒ Object
107 108 109 |
# File 'opal/opal/corelib/method.rb', line 107 def bind_call(object, *args, &block) bind(object).call(*args, &block) end |
#comments ⇒ Object
92 93 94 |
# File 'opal/opal/corelib/method.rb', line 92 def comments `#{@method}.$$comments` || [] end |
#inspect ⇒ Object
111 112 113 |
# File 'opal/opal/corelib/method.rb', line 111 def inspect "#<#{self.class}: #{@source}##{@name} (defined in #{@owner} in #{source_location.join(':')})>" end |
#parameters ⇒ Object
84 85 86 |
# File 'opal/opal/corelib/method.rb', line 84 def parameters `#{@method}.$$parameters` end |
#source_location ⇒ Object
88 89 90 |
# File 'opal/opal/corelib/method.rb', line 88 def source_location `#{@method}.$$source_location` || ['(eval)', 0] end |