Module: CZTop::HasFFIDelegate::ClassMethods
- Includes:
- Forwardable
- Included in:
- Actor, CertStore, Certificate, Config, Frame, Message, Poller::ZPoller, Socket, Z85
- Defined in:
- lib/cztop/has_ffi_delegate.rb
Overview
Some class methods related to FFI delegates.
Instance Method Summary collapse
-
#ffi_delegate(method) ⇒ void
Delegate specified instance method to the registered FFI delegate.
-
#from_ffi_delegate(ffi_delegate) ⇒ CZTop::*
Allocates a new instance and attaches the FFI delegate to it.
Instance Method Details
#ffi_delegate(method) ⇒ void
It only takes one method name so it’s easy to add some documentation for each delegated method.
This method returns an undefined value.
Delegate specified instance method to the registered FFI delegate.
81 82 83 |
# File 'lib/cztop/has_ffi_delegate.rb', line 81 def ffi_delegate(method) def_delegator(:@ffi_delegate, method) end |
#from_ffi_delegate(ffi_delegate) ⇒ CZTop::*
#initialize won’t be called on the fresh object. This works around the fact that #initialize usually assumes that no FFI delegate is attached yet and will try to do so (and also expect to be called in a specific way).
Allocates a new instance and attaches the FFI delegate to it. This is useful if you already have an FFI delegate and need to attach it to a fresh high-level object.
94 95 96 97 98 |
# File 'lib/cztop/has_ffi_delegate.rb', line 94 def from_ffi_delegate(ffi_delegate) obj = allocate obj.attach_ffi_delegate(ffi_delegate) obj end |