Add __tostring metamethods to prototypes

This is nice to have, and aids with debugging and interactive usage.
This commit is contained in:
Adrian Perez de Castro
2016-06-23 04:07:01 +03:00
parent ec288bf9fd
commit 56a57f2e89
3 changed files with 25 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ end
local API = {}
API.__name = "matrix.api"
API.__index = API
setmetatable(API, { __call = function (self, base_url, token, http_factory)
@@ -40,6 +41,10 @@ setmetatable(API, { __call = function (self, base_url, token, http_factory)
}, API)
end })
function API:__tostring()
return self.__name .. "{" .. self.base_url .. "}"
end
function API:_quote(string)
return self._http:quote(string)
end