Class: React::NativeLibrary
Overview
Public methods used by auto-import.rb are import_const_from_native and find_and_render_component
Class Method Summary collapse
- .const_missing(const_name) ⇒ Object
- .import_const_from_native(klass, const_name, create_library) ⇒ Object
- .imports(native_name) ⇒ Object
- .method_missing(method, *args, &block) ⇒ Object
- .rename(rename_list) ⇒ Object
Class Method Details
.const_missing(const_name) ⇒ Object
44 45 46 |
# File 'lib/react/native_library.rb', line 44 def const_missing(const_name) import_const_from_native(self, const_name, true) || super end |
.import_const_from_native(klass, const_name, create_library) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/react/native_library.rb', line 35 def import_const_from_native(klass, const_name, create_library) native_name = lookup_native_name(const_name) || lookup_native_name(const_name[0].downcase + const_name[1..-1]) native_name && ( create_component_wrapper(klass, native_name, const_name) || ( create_library && create_library_wrapper(klass, native_name, const_name))) end |
.imports(native_name) ⇒ Object
16 17 18 19 |
# File 'lib/react/native_library.rb', line 16 def imports(native_name) @native_prefix = "#{native_name}." self end |
.method_missing(method, *args, &block) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/react/native_library.rb', line 48 def method_missing(method, *args, &block) component_class = const_get(method) if const_defined?(method, false) component_class ||= import_const_from_native(self, method, false) raise 'could not import a react component named: '\ "#{scope_native_name method}" unless component_class React::RenderingContext.render(component_class, *args, &block) end |
.rename(rename_list) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/react/native_library.rb', line 21 def rename(rename_list) # rename_list is a hash in the form: native_name => ruby_name, native_name => ruby_name rename_list.each do |js_name, ruby_name| native_name = lookup_native_name(js_name) if lookup_native_name(js_name) create_component_wrapper(self, native_name, ruby_name) || create_library_wrapper(self, native_name, ruby_name) else raise "class #{name} < React::NativeLibrary could not import #{js_name}. "\ "Native value #{scope_native_name(js_name)} is undefined." end end end |