Sha256: 54550a9efa7375c8c9aa1f2a2961b4360d45da656f364901bbe0bc56023a1cf2

Contents?: true

Size: 961 Bytes

Versions: 83

Compression:

Stored size: 961 Bytes

Contents

module Preact
  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.Preact.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.Preact.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

83 entries across 83 versions & 1 rubygems

Version Path
isomorfeus-preact-10.9.0 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.8.2 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.8.1 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.8.0 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.7.3 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.7.2 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.7.1 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.7.0 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.62 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.61 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.60 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.59 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.58 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.57 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.56 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.55 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.54 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.53 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.52 lib/preact/native_constant_wrapper.rb
isomorfeus-preact-10.6.51 lib/preact/native_constant_wrapper.rb