matthewdean / proxy.lua

Control access to objects in pure Lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proxy.lua

Control access to Lua objects.

local proxy = require('proxy').new()

proxy:override('__index', function(t, k)
  print('indexing ', t, 'at', k)
  return t[k]
end)

-- calling proxy() wraps the given object and returns a proxy object
_G = proxy(_G)
print(_G._VERSION)

You can also override specific values:

proxy:override(loadstring, nil)
print(loadstring) --> nil

About

Control access to objects in pure Lua


Languages

Language:Lua 100.0%