module GMSEC::API::Finalizer

Public Class Methods

new(*args, **kwargs) click to toggle source

Allows us to specify destroy! to be called on an instance during GC.

Calls superclass method
# File lib/gmsec/api.rb, line 6
def initialize(*args, **kwargs)
  ObjectSpace.define_finalizer(self, self.class.method(:destroy!).to_proc)

  # If there is a `native_value` keyword argument supplied, assign
  # the value to native_object
  if native_object = kwargs.delete(:native_object)
    @native_object = native_object
  else
    if respond_to? :native_object_initializer
      initialize_native_object do |pointer|
        native_object_initializer(pointer)
      end
    end
  end

  if kwargs.empty?
    super(*args)
  else
    super(*args, **kwargs)
  end
end