| 65 | | sub element_get { |
| 66 | | my ($self, %args) = @_; |
| 67 | | |
| 68 | | my @nodes = $self->storage->findnodes_from_tagname( |
| 69 | | tag => $args{tag}, |
| 70 | | namespace => $args{namespace}, |
| 71 | | strip => 1, |
| 72 | | ); |
| 73 | | |
| 74 | | return wantarray ? @nodes : $nodes[0]; |
| 75 | | } |
| 76 | | |
| 77 | | |
| 78 | | sub __mk_element_accessor { |
| 79 | | my $class = shift; |
| 80 | | my $element = shift; |
| 81 | | my $code = sprintf(<<'EOSUB', blessed $class || $class, $element, $element); |
| 82 | | sub %s::%s { |
| 83 | | my $self = shift; |
| 84 | | my $namespace = $self->namespace; |
| 85 | | my $tag = '%s'; |
| 86 | | return @_ ? |
| 87 | | $self->element_set(namespace => $namespace, tag => $tag, value => $_[0]) : |
| 88 | | $self->element_get(namespace => $namespace, tag => $tag); |
| 89 | | } |
| 90 | | EOSUB |
| 91 | | eval $code; |
| 92 | | confess $@ if $@; |
| 93 | | } |
| 94 | | |
| 95 | | |
| 96 | | # These accessors must differ how they act depending on if the feed is |