Subject:
[ruby-ffi] Make functions private by default?
From:
Daniel Berger
Date:
6/9/12 10:25 AM
To:
ruby-ffi

Hi,

Is there a way to make the FFI function declarations private by
default? I want to use the functions internally only. I don't want
them exposed as part of a public API. Simply using the "private"
keyword doesn't seem to work. Consider:

require 'ffi'

module Windows
  extend FFI::Library
  ffi_lib :kernel32

  private

  attach_function :CloseHandle, [:ulong], :bool
end

p Windows.methods(false) # => [:CloseHandle]

The only way to make it work is to call private_class_method on the
functions after the fact, so it can be done. I was just hoping there
was a nicer way to do them "en masse" as it were.

Perhaps if attach_function is called in the context of private
automatically declare them private_class_methods? Although I don't
actually know if that's possible in Ruby. :)

Regards,

Dan