Sha256: 81ecf71d3aec97fc5edd68372d747e93a472fb07b6491aebeac7b6d96066cde0

Contents?: true

Size: 909 Bytes

Versions: 16

Compression:

Stored size: 909 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 {
          #{raise NameError, "No such native Component #@const_name.#{name}"};
        }
      }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
isomorfeus-react-16.12.11 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.10 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.9 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.8 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.7 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.6 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.5 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.4 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.3 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.2 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.1 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.12.0 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.11.4 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.11.3 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.11.2 lib/react/native_constant_wrapper.rb
isomorfeus-react-16.11.1 lib/react/native_constant_wrapper.rb