# This exists to provide object-specific can() functionality. # 1) If this is an object, check to see if the method is an element name. # 2) If either is not true, redispatch to the parent's can() method. sub can { ( ref($_[0]) && UNIVERSAL::isa( $_[0]->elements, 'HASH' ) && exists $_[0]->elements->{$_[1]} ) || ( $_[0]->SUPER::can($_[1]) ); } sub AUTOLOAD { (my $name = our $AUTOLOAD) =~ s/.*::([^:]+)$/$1/; my $self = shift; unless ($name eq lc $name || exists $self->element_classes->{lc $name}) { return eval "$self->SUPER::$meth(@_);"; } $self->elements->{$name} = shift if @_; $self->elements->{$name}; }