Just now getting my feet wet with computed properties; however, I do have one simple question… what are the attributes for in the inspector panel?
Also, for those that refer me to the language reference… I’ve tried and tried to get information on the “computed property” with no luck. I’ve searched “computedproperty” “computed property” “property”, etc. The search feature seems to be lacking… unless I’m just completely failing.
I’m aware of only two valid choices for attributes (although I suppose you could create your own): Deprecated and Hidden.
Deprecated will let you mark something as, well, deprecated so, if you are still using it in your project, a compiler warning will appear. The value is the alternate method/property to use instead.
Hidden will keep that item from showing up in auto-complete. No value is needed. You’d use it to make a method/property publicly available, but it hide it from use. A great example of when you might use this is a SelfTest method for a class or module.
I’d read Aarons blog post about attributes from when they were introduced back in 2008 (r3)
They are compile & runtime bits of meta data
So you can put in whatever you might want but say you had a system that generated classes for an ORM you could use an attribute to say which table the class was derived from
I use attributes in my OrmRecord class. From the Inspector, you can add things such as OrmSkip (skips mapping to the table), OrmName (overrides the computed name of a field), OrmConvert (specifies a conversion method for reading to/from the table). Pretty cool stuff really.
(can’t edit post again for some reason)… oh… also Attributes exist everywhere, not just on computed properties. For example, in my OrmRecord example, OrmName works on a Class (ClaimStatus -> claim_status table) or you could simply add a OrmName attribute of “claim_statuses” to override the computed table name.
For more about attributes, you can check out User Guide Book 3: Framework, Chapter 10: Advanced Features, Section 9: Attributes. Other than the two special “Deprecated” and “Hidden” attributes, you only would use them with introspection.