view Lib/IMPL/Web/TT/Collection.pm @ 197:6b1dda998839

Added IMPL::declare, IMPL::require, to simplify module definitions IMPL::Transform now admires object inheritance while searching for the transformation Added HTTP some exceptions IMPL::Web::Application::RestResource almost implemented
author sergey
date Thu, 19 Apr 2012 02:10:02 +0400
parents 4d0e1962161c
children
line wrap: on
line source

package IMPL::Web::TT::Collection;
use strict;

use parent qw(IMPL::DOM::Node);

__PACKAGE__->PassThroughArgs;

our $AUTOLOAD;
sub AUTOLOAD {
    my $this = shift;
    my ($method) = ($AUTOLOAD =~ /(\w+)$/);
    
    return if $method eq 'DESTROY';
    
    if ( @_ >= 1 ) {
        # set
        
        if ($method =~ /^add(\w+)/) {
            my ($name,$args) = @_;
            return $this->appendChild($this->document->CreateControl($name,$1,$args));
        }
        
        # we can't assing a node, so this is a dynamic property
        return $this->nodeProperty($method,@_);
    } else {
        # get
        # try a dynamic property first 
        if ( my $val = $this->nodeProperty($method) ) {
            return $val;
        } else {
        # and return a first child node as last opportunity
            my @result = $this->selectNodes($method);
    
            return $result[0] if @result;
        }
    }
    
    return;
}

1;