Stupid Moose Questions
I have always embodied the perl virtue of laziness. Well, at least I've tried most times. Most times, this is good, since it helps me to write small, well tested code that is easy to maintain. Other times, it's bad, since I've never learned Moose or DBI::Class.
Recently, the decision was made to have WebGUI move over to Moose. I spent a lot of time reading POD and slides and online articles, and then began the task of setting up metaclasses and roles for WebGUI.
Several times, I found myself wanting to get all the attributes of a metaclass as objects. This can be done by iterating over the names, and then then calling $meta->find_attribute_by_name($name). But inside Class::MOP::Class they're all stored in a hash inside of a private method, _attribute_map(), there's simply no "public" way to get the values of that hash. Why isn't there a $meta->get_attributes?
Similarly, you can get a set of all attributes as objects across all metaclasses, but you can't get their names without again, iterating across all the objects one by one. So why isn't there a $meta->get_all_attributes_list?
Don't get me wrong. I love Moose. Even with the little that I've done, it's already made WebGUI easier to maintain and more reliable. I'm guessing the problem is that I'm not thinking in the Moose way yet, and doing things awkwardly.