Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/reactrb/auto-import.rb,
lib/react/rendering_context.rb
Overview
modifies const and method_missing so that they will attempt to auto import native libraries and components using React::NativeLibrary
Class Method Summary collapse
- ._reactrb_original_const_missing ⇒ Object
- ._reactrb_original_method_missing ⇒ Object
- .const_missing(const_name) ⇒ Object
- .method_missing(method_name, *args, &block) ⇒ Object
Instance Method Summary collapse
Class Method Details
._reactrb_original_const_missing ⇒ Object
9 |
# File 'lib/reactrb/auto-import.rb', line 9 alias _reactrb_original_const_missing const_missing |
._reactrb_original_method_missing ⇒ Object
10 |
# File 'lib/reactrb/auto-import.rb', line 10 alias _reactrb_original_method_missing method_missing |
.const_missing(const_name) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/reactrb/auto-import.rb', line 12 def const_missing(const_name) # Opal uses const_missing to initially define things, # so we always call the original, and respond to the exception _reactrb_original_const_missing(const_name) rescue StandardError => e React::NativeLibrary.import_const_from_native(Object, const_name, true) || raise(e) end |
.method_missing(method_name, *args, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/reactrb/auto-import.rb', line 20 def method_missing(method_name, *args, &block) method = method_name.gsub(/_as_node/, '') # remove once _as_node is deprecated. component_class = React::NativeLibrary.import_const_from_native(self, method, false) _reactrb_original_method_missing(method, *args, &block) unless component_class if method == method_name React::RenderingContext.render(component_class, *args, &block) else # remove once _as_node is deprecated. React::RenderingContext.build_only(component_class, *args, &block) end end |
Instance Method Details
#br ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/react/rendering_context.rb', line 98 def br return send(:br) if is_a? React::Component React::RenderingContext.render(:span) do React::RenderingContext.render(to_s) React::RenderingContext.render(:br) end end |