def alias_native(new, old = new, as: nil)
      if old.end_with? '='
        define_method new do |value|
          `#{@native}[#{old[0..-2]}] = #{Native.convert(value)}`

          value
        end
      elsif as
        define_method new do |*args, &block|
          value = Native.call(@native, old, *args, &block)
          if value
            as.new(value.to_n)
          end
        end
      else
        define_method new do |*args, &block|
          Native.call(@native, old, *args, &block)
        end
      end
    end
def alias_native(new, old = new, as: nil)
      if old.end_with? '='
        define_method new do |value|
          `#{@native}[#{old[0..-2]}] = #{Native.convert(value)}`

          value
        end
      elsif as
        define_method new do |*args, &block|
          value = Native.call(@native, old, *args, &block)
          if value
            as.new(value.to_n)
          end
        end
      else
        define_method new do |*args, &block|
          Native.call(@native, old, *args, &block)
        end
      end
    end
Exposes a native JavaScript method to Ruby


 @param new [String]
       The name of the newly created method.

 @param old [String]
       The name of the native JavaScript method to be exposed.
       If the name ends with "=" (e.g. `foo=`) it will be interpreted as
       a property setter. (default: the value of "new")

 @param as [Class]
       If provided the values returned by the original method will be
       returned as instances of the passed class. The class passed to "as"
       is expected to accept a native JavaScript value.

 @example

   class Element
     extend Native::Helpers

     alias_native :add_class, :addClass
     alias_native :show
     alias_native :hide

     def initialize(selector)
       @native = `$(#{selector})`
     end
   end

   titles = Element.new('h1')
   titles.add_class :foo
   titles.hide
   titles.show