1 package MOBY
::Client
::SimpleInput
;
4 use vars
qw($AUTOLOAD @ISA);
8 MOBY::Client::SimpleInput - a small object describing a MOBY service
26 Usage : my $IN = MOBY::Client::SimpleInput->new(%args)
27 Function : create SimpleInput object
28 Returns : MOBY::Client::SimpleInput object
29 Args : articleName => $articleName (optional)
30 objectType => $objectType (required)
31 namespaces => \@namesapces (optional)
37 Usage : $name = $IN->articleName([$name])
38 Function : get/set articleName
46 Usage : $type = $IN->objectType([$type])
47 Function : get/set name
55 Usage : $namespaces = $IN->namespaces([\@namespaces])
56 Function : get/set namespaces for the objectType
57 Returns : arrayref of namespace strings
64 Usage : $namespaces = $IN->addNamespace($namespace)
65 Function : add another namespace for the objectType
66 Returns : arrayref of namespace strings
74 #___________________________________________________________
76 my %_attr_data = # DEFAULT ACCESSIBILITY
78 articleName => [ undef, 'read/write' ],
79 objectType => [ undef, 'read/write' ],
80 namespaces => [ [], 'read/write' ],
83 #_____________________________________________________________
84 # METHODS, to operate on encapsulated class data
85 # Is a specified object attribute accessible in a given mode
87 my ( $self, $attr, $mode ) = @_;
88 $_attr_data{$attr}[1] =~ /$mode/;
91 # Classwide default value for a specified object attribute
93 my ( $self, $attr ) = @_;
94 $_attr_data{$attr}[0];
97 # List of names of all specified object attributes
103 my ( $self, $ns ) = @_;
104 return $self->{namespaces} unless $ns;
105 push @{ $self->{namespaces} }, $ns;
106 return $self->{namespaces};
111 my ( $caller, %args ) = @_;
112 my $caller_is_obj = ref( $caller );
113 return $caller if $caller_is_obj;
114 my $class = $caller_is_obj || $caller;
116 my $self = bless {}, $class;
117 foreach my $attrname ( $self->_standard_keys ) {
118 if ( exists $args{$attrname} ) {
119 $self->{$attrname} = $args{$attrname};
120 } elsif ( $caller_is_obj ) {
121 $self->{$attrname} = $caller->{$attrname};
123 $self->{$attrname} = $self->_default_for( $attrname );
131 my ( $self, $newval ) = @_;
132 $AUTOLOAD =~ /.*::(\w+)/;
134 if ( $self->_accessible( $attr, 'write' ) ) {
136 if ( defined $_[1] ) { $_[0]->{$attr} = $_[1] }
137 return $_[0]->{$attr};
138 }; ### end of created subroutine
139 ### this is called first time only
140 if ( defined $newval ) {
141 $self->{$attr} = $newval;
143 return $self->{$attr};
144 } elsif ( $self->_accessible( $attr, 'read' ) ) {
146 return $_[0]->{$attr};
147 }; ### end of created subroutine
148 return $self->{$attr};
151 # Must have been a mistake then...
152 croak "No such method: $AUTOLOAD";