--[=[
	The value of the ValueObject
	@prop Value T
	@within ValueObject
]=]

function ValueObject:__index(index)
	if index == "Value" then
		return self._value
	elseif ValueObject[index] then
		return ValueObject[index]
	elseif index == "_value" then
		return nil -- Edge case
	else
		error(("%q is not a member of ValueObject"):format(tostring(index)))
	end
end

function ValueObject:__newindex(index, value)
	if index == "Value" then
		local previous = rawget(self, "_value")
		if previous ~= value then
			rawset(self, "_value", value)

			local maid = Maid.new()

			self.Changed:Fire(value, previous, maid)

			self._maid._valueMaid = maid
		end
	else
		error(("%q is not a member of ValueObject"):format(tostring(index)))
	end
end
