A software container for metadata that defines an attribute of a Myco Entity class.
To add an attribute to a class, the constructor of Myco::Base::Entity::Meta::Attribute should be only accessed via ::Meta's add_attribute() as demonstrated in the following syntax:
my $md = Myco::Base::Entity::Meta( name => __PACKAGE__ );
$md->add_attribute(
name => 'doneness',
type => 'int',
readonly => 0, # default is read/write
access_list => {
rw => ['admin'],
ro => [qw(average_joes junior_admins)]
},
tangram_options => { required => 1},
synopsis => "How you'd like your meat cooked",
syntax_msg => "correct format, please!",
values => [qw(0 1 2 3 4 5)],
value_labels => {
0 => 'rare',
1 => 'medium-rare',
2 => 'medium',
3 => 'medium-well',
4 => 'well',
5 => 'charred'
},
ui => {
widget => [ 'popup_menu' ],
label => 'Cook until...',
},
);
For typical post-setup usage, a reference to an array of Myco::Base::Entity::Meta::Attribute objects can be obtained for an entity object's class. This can be done by calling $metadata->get_attributes(). To look up an attribute's type, one can use $attributes->{doneness}->get_type(). The stored accessor coderef can also be accessed to set values such as doneness=3 using $attributes->{doneness}->setval($obj, 3).
Overall, Myco::Base::Entity::Meta::Attribute is a versatile tool that can enhance the functionality of a software developer's repertoire.
Version 0.01: N/A