Subject:
Re: [ruby-ffi] Make functions private by default?
From:
Matijs van Zuijlen
Date:
6/9/12 10:52 AM
To:
ruby-ffi@googlegroups.com

Hi Daniel,

You can easily create a method attach_function_privately that combines the calls
to attach_function and private_class_method.

Regards,
Matijs

On 09/06/12 17:25, Daniel Berger wrote:
> 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


-- Matijs