Class: Rufus::Lua::Ref
- Inherits:
-
Object
- Object
- Rufus::Lua::Ref
- Defined in:
- lib/immunio/rufus_lua_ext/ref.rb
Overview
Auto-unref Lua ref when it goes out of scope in Ruby.
Class Method Summary collapse
Instance Method Summary collapse
- #free ⇒ Object
- #initialize_with_finalizer(*args) ⇒ Object (also: #initialize)
Class Method Details
.finalize(pointer, ref) ⇒ Object
12 13 14 15 16 |
# File 'lib/immunio/rufus_lua_ext/ref.rb', line 12 def self.finalize(pointer, ref) proc do Lib.luaL_unref(pointer, LUA_REGISTRYINDEX, ref) end end |
Instance Method Details
#free ⇒ Object
19 20 21 |
# File 'lib/immunio/rufus_lua_ext/ref.rb', line 19 def free # Noop. Taken care of by finalizer. Should not conflict. end |
#initialize_with_finalizer(*args) ⇒ Object Also known as: initialize
4 5 6 7 8 |
# File 'lib/immunio/rufus_lua_ext/ref.rb', line 4 def initialize_with_finalizer(*args) initialize_without_finalizer(*args) ObjectSpace.define_finalizer self, self.class.finalize(@pointer, @ref) end |