Class::Dot::Type

Base class for type constraints
Download

Class::Dot::Type Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ask Solem
  • Publisher web site:
  • http://search.cpan.org/~asksh/Modwheel-0.3.3/lib/Modwheel.pm

Class::Dot::Type Tags


Class::Dot::Type Description

Base class for type constraints Class::Dot::Type is a base Perl class for type constraints.SYNOPSIS # You probably want to get this information from your instance's __meta__ # attriute. package MyClass; use Class::Dot2; property 'name' => (isa => 'Str', default => 'Mr. Fox Quick Brown'); sub play_with_attribute_meta { my ($self) = @_; my $name_meta = $self->__meta__('name'); # Get the name of the type for attribute name. my $type = $name_meta->type; # Find out what kind of accessor this is. (default: Overridable) my $accessor_type = $name_meta->accessor_type; # Get a subroutine ref to the constraint check for this type. my $check_constraint = $name_meta->constraint; my $current_value = $self->name; if (! $check_constraint->($current_value)) { croak "Value of name does not pass the constraint check for $type" } # Get the getter and setter name. my $getter_name = $name_meta->getter_name; my $setter_name = $name_meta->setter_name; # get the value by calling name(): $current_value = $self->$getter_name; # set the value by calling set_name($value) $self->$setter_name('new value'); # Get the list of parents for this type. my @isa_for_type = $meta->linear_isa; # Get the privacy option for this type (default: public (rw)). my $privacy_type = $meta->privacy; # Get the privacy rules for this privacy type. my $privacy_rules = $meta->privacy_rule; print $privacy_rules->{has_getter}; print $privacy_rules->{has_setter}; return; } Requirements: · Perl


Class::Dot::Type Related Software