Add define function, maintain backward compatibility
Accept Closures as attribute factory