Myco::Base::Entity::Meta::Attribute is a container for meta data describing an attribute of a Myco Entity class.
SYNOPSIS
# Note this class is normally used only via
# Myco::Base::Entity::Meta
## Within an entity class definition - add attribute to class
# ::Attribute's constructor should only be used via
# ::Meta's add_attribute() as shown:
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...',
},
);
## Typical post-setup usage
# ...given a Myco::Base::Entity::Meta enabled entity object $obj
my $metadata = $obj->introspect;
# Get reference to array of ::Meta::Attribute objects for $obj's class
my $attributes = $metadata->get_attributes;
# Look up attribute's type
my $type = $attributes->{doneness}->get_type;
# Use of stored accessor coderef - set doneness = 3
$attributes->{doneness}->setval($obj, 3);
Product's homepage
Requirements:
· Perl