{"id":"north-dev-x/ezobj","name":"ezobj","scope":"north-dev-x","platform":"roblox","description":"An easy-to-use OOP implementation for Roblox.","version":"0.6.0","latest":"0.6.0","versions":["0.3.0","0.4.0","0.5.0","0.6.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":["The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{},"integrity":"0a2107813aa5a694718813d90afa1bf61b2caac3b6d093303d8babe26ddc79c6","likes":0,"downloads":0,"install":"forest install north-dev-x/ezobj","url":"https://forest.dev/p/roblox/north-dev-x/ezobj","files":"https://api.forest.dev/ai/package/roblox/north-dev-x/ezobj/files","readme":"ezobj is a Luau library for simple and straightforward class/object/struct creation.\n\nRather than having to deal with metatables, ezobj handles all of that and more behind the scenes while you code in peace!\n\n[Toolbox Link](https://create.roblox.com/store/asset/111257770848071/ezobj)\n\n[Wally](https://wally.run/package/north-dev-x/ezobj)\n\n### Usage Example\nezobj allows you to easily create classes and derivative classes.\n```luau\n--[[\nname this variable whatever your favorite class/object keyword is,\ni.e struct, class, def, defstruct, etc\n]] \nlocal class = require(path-to-ezobj)\n\nlocal SomeClass = class {\n\tfield = 3;\n\t-- a singleton function does not need a self parameter and can be called with class.method() without problem\n\thello_world = function()\n\t\tprint(\"Hello, world!\")\n\tend;\n\t-- Initialize the first argument as `self: any?` to access class fields and methods\n\t-- A function with self: any? must be called with class:method() to work properly\n\tmethod = function(self: any?, val: number) \n\t\tif self then\n\t\t\tself.field = val\n\t\t\tprint(self.field)\n\t\tend\n\tend;\n}\ntype SomeClass = typeof(SomeClass) -- define class type to use as a type hint if wanted later\n\n-- call singleton method without constructing the class\nSomeClass.hello_world()\n\nlocal x = SomeClass.new() -- construct an instance of the class\nx:method(42) -- 42\n\n-- extend SomeClass into a new class\nlocal ExtendClass = SomeClass:extend {\n\tfield = \"something\"; -- overrides field from superclass\n\t-- self can also be initialized using the class type if you don't want to check if self exists every time, this is especially helpful when using strict mode\n\tmethod = function(self: ExtendClass, val: string)\n\t\treturn val..self.field\n\tend;\n}\ntype ExtendClass = typeof(ExtendClass) -- used internally in the class for self\n\n-- construct an instance of the class with a default value\nlocal y = ExtendClass.new {\n\tfield = \"Hello,\"\n}\nprint(y:method(\" world!\")) -- Hello, world!\ny.hello_world() -- Hello, world! - retains method from superclass\n\ny.super:method(500) -- 500 - Access superclass methods with class.super\n```\n\n### Documentation\n[Classes](Classes.md)\n\n[Abstract Classes and Interfaces](Abstract%20Classes%20and%20Interfaces.md)\n\n[Classes are first-class objects](Classes%20are%20first-class%20objects.md)\n","readmeTruncated":false}