Sha256: d63120ee50b444809d00a7d1d709f3b8547191f606b7fd3407dca5d5d9f54bf2
Contents?: true
Size: 1.38 KB
Versions: 8
Compression:
Stored size: 1.38 KB
Contents
# rubocop:disable Style/FileName # require 'reactrb/auto-import' to automatically # import JS libraries and components when they are detected if RUBY_ENGINE == 'opal' # modifies const and method_missing so that they will attempt # to auto import native libraries and components using React::NativeLibrary class Object class << self alias _reactrb_original_const_missing const_missing alias _reactrb_original_method_missing method_missing 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 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 end end end
Version data entries
8 entries across 8 versions & 2 rubygems