zoukankan      html  css  js  c++  java
  • LUA_OBJECT

    --
    -- classic, object model.
    --
    -- Copyright (c) 2014, rxi
    --
    -- This module is free software; you can redistribute it and/or modify it under
    -- the terms of the MIT license. See LICENSE for details.
    --
    -- Base object model used with Kong, see [classic github repo](https://github.com/rxi/classic) for usage information

    local Object = {}
    Object.__index = Object

    function Object:new()
    end

    function Object:extend()
    local cls = {}
    for k, v in pairs(self) do
    if k:find("__") == 1 then
    cls[k] = v
    end
    end
    cls.__index = cls
    cls.super = self
    setmetatable(cls, self)
    return cls
    end
    function Object:implement(...)
    for _, cls in pairs({...}) do
    for k, v in pairs(cls) do
    if self[k] == nil and type(v) == "function" then
    self[k] = v
    end
    end
    end
    end
    function Object:is(T)
    local mt = getmetatable(self)
    while mt do
    if mt == T then
    return true
    end
    mt = getmetatable(mt)
    end
    return false
    end
    function Object:__tostring()
    return "Object"
    end
    function Object:__call(...)
    local obj = setmetatable({}, self)
    obj:new(...)
    return obj
    end
    return Object
  • 相关阅读:
    转载:GPRS发短信代码
    如何辨别假币
    【转载】软件开发方向的大学生应该学什么
    第一次喝吐了
    挑战世界2%
    45、c_str与data()
    2、Get和post的区别
    4、suse11安装apache
    1、学习用c/c++写cgi程序
    4、安装rz/sz
  • 原文地址:https://www.cnblogs.com/justart/p/12383886.html
Copyright © 2011-2022 走看看