Module: __JS__::Opal

Defined in:
opal/opal/corelib/runtime.js.rb

Overview

This module is just a placeholder for showing the documentation of the internal JavaScript runtime. The methods you'll find defined below are actually JavaScript functions attached to the Opal global object

Class Method Summary collapse

Class Method Details

.const_get_nameObject

Get the constant in the scope of the current cref



7
8
9
10
11
12
13
# File 'opal/opal/corelib/runtime.js.rb', line 7

def self.const_get_name(*)
<<-JAVASCRIPT
   function const_get_name(cref, name) {
     if (cref) return cref.$$const[name];
   }
JAVASCRIPT
end

.const_lookup_ancestorsObject

Walk up the ancestors chain looking for the constant



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'opal/opal/corelib/runtime.js.rb', line 36

def self.const_lookup_ancestors(*)
<<-JAVASCRIPT
   function const_lookup_ancestors(cref, name) {
     var i, ii, result, ancestors;
   
     if (cref == null) return;
   
     ancestors = Opal.ancestors(cref);
   
     for (i = 0, ii = ancestors.length; i < ii; i++) {
       if (ancestors[i].$$const && $hasOwn.call(ancestors[i].$$const, name)) {
         return ancestors[i].$$const[name];
       }
     }
   }
JAVASCRIPT
end

.const_lookup_nestingObject

Walk up the nesting array looking for the constant



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'opal/opal/corelib/runtime.js.rb', line 17

def self.const_lookup_nesting(*)
<<-JAVASCRIPT
   function const_lookup_nesting(nesting, name) {
     var i, ii, result, constant;
   
     if (nesting.length === 0) return;
   
     // If the nesting is not empty the constant is looked up in its elements
     // and in order. The ancestors of those elements are ignored.
     for (i = 0, ii = nesting.length; i < ii; i++) {
       constant = nesting[i].$$const[name];
       if (constant != null) return constant;
     }
   }
JAVASCRIPT
end

.const_lookup_ObjectObject

Walk up Object's ancestors chain looking for the constant, but only if cref is missing or a module.



57
58
59
60
61
62
63
64
65
# File 'opal/opal/corelib/runtime.js.rb', line 57

def self.const_lookup_Object(*)
<<-JAVASCRIPT
   function const_lookup_Object(cref, name) {
     if (cref == null || cref.$$is_module) {
       return const_lookup_ancestors(_Object, name);
     }
   }
JAVASCRIPT
end

.const_missingObject

Call const_missing if nothing else worked



69
70
71
72
73
74
75
76
77
# File 'opal/opal/corelib/runtime.js.rb', line 69

def self.const_missing(*)
<<-JAVASCRIPT
   function const_missing(cref, name, skip_missing) {
     if (!skip_missing) {
       return (cref || _Object).$const_missing(name);
     }
   }
JAVASCRIPT
end