Sha256: 35c04bd52a67c195dff9d8c706c41022bdbcc29ad9cbeebdf16a2c685ee8b8cb

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

module React
  class NativeConstantWrapper
    include ::Native::Wrapper

    def initialize(native, const_name)
      @native = native
      @const_name = const_name
    end

    def method_missing(name, *args, &block)
      %x{
        if (name[0] === 'u' && name[1] === 's' && name[2] === 'e') {
          if (name.indexOf('_') > 0) { name = Opal.React.lower_camelize(name); }
          return #@native[name].call(this, args);
        }
        var component = null;
        var component_type = typeof #@native[name];
        if (component_type === "function" || component_type === "object") {
          component = #@native[name];
        }
        if (component) {
          return Opal.React.internal_prepare_args_and_render(component, args, block);
        } else {
          #{Isomorfeus.raise_error(error_class: NameError, message: "No such native Component #@const_name.#{name}")};
        }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
isomorfeus-react-16.13.12 lib/react/native_constant_wrapper.rb