local v=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\118\101\114\109\111\114\101"))local E=v("\083\116\114\105\110\103")local F={}function F.Add(F,v,E)assert(v)assert(E)F.GenerateWith(v,E)end function F.GenerateWith(v,F)assert(type(F)=="\116\097\098\108\101")for F,N in ipairs(F)do local Q=E.ToPrivateCase(N)v[("\087\105\116\104\037\115"):format(N)]=function(v,E)v[Q]=E or error(("\070\097\105\108\101\100 \116\111 \115\101\116 \'\037\115\'\044 \037\115"):format(N,tostring(E)))v[N]=E return v end v[("\071\101\116\037\115"):format(N)]=function(v)return v[Q]end end return v end return F
--- Simple mixin to generate code for a class
-- @module GenerateWithMixin

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))

local String = require("String")

local GenerateWithMixin = {}

--- Adds the GenerateWith API to the class
-- @tparam table class
-- @tparam table staticResources These resources are added to the class automatically
function GenerateWithMixin:Add(class, staticResources)
	assert(class)
	assert(staticResources)

	self.GenerateWith(class, staticResources)
end

--- Generates resources
-- @tparam table resources Resources to add
function GenerateWithMixin.GenerateWith(class, resources)
	assert(type(resources) == "table")

	for _, resourceName in ipairs(resources) do
		local storeName = String.ToPrivateCase(resourceName)

		class[("With%s"):format(resourceName)] = function(self, resource)
			self[storeName] = resource or error(("Failed to set '%s', %s"):format(resourceName, tostring(resource)))
			self[resourceName] = resource -- inject publically too, for now
			return self
		end

		class[("Get%s"):format(resourceName)] = function(self)
			return self[storeName]
		end
	end

	return class
end

return GenerateWithMixin
