--[=[
	Signal that fires when the attribute changes
	@readonly
	@prop Changed Signal<()>
	@within AttributeValue
]=]

function AttributeValue:__index(index)
	if index == "Value" then
		local result = self._object:GetAttribute(rawget(self, "_attributeName"))
		local default = rawget(self, "_defaultValue")
		if result == nil then
			return default
		else
			return result
		end
	elseif index == "Changed" then
		return self._object:GetAttributeChangedSignal(self._attributeName)
	elseif AttributeValue[index] then
		return AttributeValue[index]
	else
		error(("%q is not a member of AttributeValue"):format(tostring(index)))
	end
end

function AttributeValue:__newindex(index, value)
	if index == "Value" then
		self._object:SetAttribute(rawget(self, "_attributeName"), value)
	else
		error(("%q is not a member of AttributeValue"):format(tostring(index)))
	end
end

return AttributeValue
