Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A repository for my extensions to MiddleClass.
Lua
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
middleclass
README.md
SingleAccessor.lua
Static.lua
test_Static.lua

README.md

This is the repository for my extensions to MiddleClass, done in the style of the MiddleClass Extras.

Currently only one extension is here, which is called Static. Static's purpose is to allow you to make some functions accessible through the class alone. Normally all functions declared are accessible through the class and all instances. Here's an example of using Static:

require 'middleclass.init'
require 'Static'

Foo = class('Foo'):include(Static)

function Foo:classOnly()
  print('hello class!')
end

function Foo:classOnly2()
  print('hello class again!')
end

function Foo:normal()
  print('hello world!')
end

Foo:static('classOnly', 'classOnly2')

f = Foo()
f:normal() -- hello world!
Foo:classOnly() -- hello class!
Foo:classOnly2() -- hello class again!
f:classOnly() -- no method
Something went wrong with that request. Please try again.