The problem is that your concept is completely corrupted. You assign a map to a class, not an instance with this line:
User.metaClass.dynamicAttributes = [:]
To accomplish what you are looking for, you need to do the following:
User.metaClass.propertyMissing = { String name ->
if (!delegate.dynamicAttributes) delegate.dynamicAttributes = [:]
delegate.dynamicAttributes[name]
}
User.metaClass.propertyMissing = { String name, value ->
if (!delegate.dynamicAttributes) delegate.dynamicAttributes = [:]
delegate.dynamicAttributes[name] = value
}
, , , , .