Sha256: 6d3f912d27fa5e3a852dd1b5e4c8d39b9b5e96efb9e4951740872b0f513d3404

Contents?: true

Size: 1.12 KB

Versions: 23

Compression:

Stored size: 1.12 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, *args, &block)
        component_class = React::NativeLibrary.import_const_from_native(self, method, false)
        _reactrb_original_method_missing(method, *args, &block) unless component_class
        React::RenderingContext.render(component_class, *args, &block)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
hyper-component-0.99.6 lib/reactrb/auto-import.rb
hyper-component-0.99.5 lib/reactrb/auto-import.rb
hyper-component-0.99.4 lib/reactrb/auto-import.rb
hyper-component-0.99.3 lib/reactrb/auto-import.rb
hyper-component-0.99.2 lib/reactrb/auto-import.rb
hyper-component-0.99.1 lib/reactrb/auto-import.rb
hyper-component-0.99.0 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap28 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap27 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap26 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap25 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap24 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap23 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap22 lib/reactrb/auto-import.rb
hyper-react-1.0.0.lap21 lib/reactrb/auto-import.rb
hyper-react-0.12.7 lib/reactrb/auto-import.rb
hyper-react-0.12.6 lib/reactrb/auto-import.rb
hyper-react-0.12.5 lib/reactrb/auto-import.rb
hyper-react-0.12.4 lib/reactrb/auto-import.rb
hyper-react-0.12.3 lib/reactrb/auto-import.rb