| 1 | package WebService::Technorati::BaseTechnoratiObject; | ||
| 2 | use strict; | ||
| 3 | use utf8; | ||
| 4 | |||
| 5 | use vars qw($AUTOLOAD); | ||
| 6 | use AutoLoader; | ||
| 7 | |||
| 8 | use WebService::Technorati::Exception; | ||
| 9 | |||
| 10 | sub AUTOLOAD { | ||
| 11 | my $self=shift; | ||
| 12 | my $change=shift; | ||
| 13 | my $class = ref($self) || $self; | ||
| 14 | my($type,$field) = $AUTOLOAD =~ /.*::((?:s|g)et)([A-Z]\w+)/; | ||
| 15 | if (! defined($field)) { | ||
| 16 | WebService::Technorati::MethodNotImplementedException->throw( | ||
| 17 | "method not implemented: $AUTOLOAD"); | ||
| 18 | } | ||
| 19 | $field = lc($field); | ||
| 20 | $self->_accessible($field) | ||
| 21 | || WebService::Technorati::AccessViolationException->throw( | ||
| 22 | "attribute not accessible in $class: $field $AUTOLOAD"); | ||
| 23 | if ($change && $type eq 'set') { | ||
| 24 | $self->{$field}=$change; | ||
| 25 | } | ||
| 26 | return $self->{$field}; | ||
| 27 | } # AUTOLOAD | ||
| 28 | |||
| 29 | sub _accessible { | ||
| 30 | my $self = shift; | ||
| 31 | my $class = ref($self) || $self; | ||
| 32 | WebService::Technorati::MethodNotImplementedException->throw( | ||
| 33 | "abstract method '_accessible' not implemented by $class"); | ||
| 34 | } | ||
| 35 | |||
| 36 | 1; | ||
| 37 | |||
| 38 | __END__ |