Yet Another Lua Object-Oriented Model


Global Functions

role( modname )

Create a Coat role as a standard Lua module.

Functions in the built Role

excludes( role [, ...] )

A role could exclude a list of other roles. = { options }

Adds a attribute name in the current role, like in a class. = func

Registers a method, like in a class.

requires( method [, ...] )

A role could require a list of method in the class which consumes it.


Like an Interface

require 'Coat.Role'

role 'Breakable'
requires '_break'
require 'Coat'

class 'Car'
with 'Breakable'

method._break = function (self)
    return "I broke"