Class: BasicObject
- Defined in:
- opal/opal/corelib/basic_object.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BasicObject
2
3
|
# File 'opal/opal/corelib/basic_object.rb', line 2
def initialize(*)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
66
67
68
|
# File 'opal/opal/corelib/basic_object.rb', line 66
def method_missing(symbol, *args, &block)
Kernel.raise NoMethodError, "undefined method `#{symbol}' for BasicObject instance"
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?, equal?
5
6
7
|
# File 'opal/opal/corelib/basic_object.rb', line 5
def ==(other)
`self === other`
end
|
#__id__ ⇒ Object
9
10
11
|
# File 'opal/opal/corelib/basic_object.rb', line 9
def __id__
`self._id || (self._id = Opal.uid())`
end
|
#__send__(symbol, *args, &block) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'opal/opal/corelib/basic_object.rb', line 13
def __send__(symbol, *args, &block)
%x{
var func = self['$' + symbol]
if (func) {
if (block !== nil) {
func._p = block;
}
return func.apply(self, args);
}
if (block !== nil) {
self.$method_missing._p = block;
}
return self.$method_missing.apply(self, [symbol].concat(args));
}
end
|
#instance_eval(&block) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'opal/opal/corelib/basic_object.rb', line 36
def instance_eval(&block)
Kernel.raise ArgumentError, "no block given" unless block
%x{
var block_self = block._s,
result;
block._s = null;
result = block.call(self, self);
block._s = block_self;
return result;
}
end
|
#instance_exec(*args, &block) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'opal/opal/corelib/basic_object.rb', line 51
def instance_exec(*args, &block)
Kernel.raise ArgumentError, "no block given" unless block
%x{
var block_self = block._s,
result;
block._s = null;
result = block.apply(self, args);
block._s = block_self;
return result;
}
end
|