Sha256: c25f9cc3d2c2e26ad996f42e77c8c928da6e2ea76489779fda08035f22686a7d

Contents?: true

Size: 949 Bytes

Versions: 20

Compression:

Stored size: 949 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)
      # language=JS
      %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

20 entries across 20 versions & 1 rubygems

Version Path
isomorfeus-react-16.13.6 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.13.5 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.13.4 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.13.3 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.13.2 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.13.1 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.13.0 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.24 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.23 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.22 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.21 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.20 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.19 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.18 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.17 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.16 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.15 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.14 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.13 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.12 lib/react/native_constant_wrapper.rb