]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/perl/lib/OpenSRF/DomainObject/oilsMethod.pm
silence some uninitialized warnings
[OpenSRF.git] / src / perl / lib / OpenSRF / DomainObject / oilsMethod.pm
1 package OpenSRF::DomainObject::oilsMethod;
2
3 use OpenSRF::Utils::JSON;
4 OpenSRF::Utils::JSON->register_class_hint(hint => 'osrfMethod', name => 'OpenSRF::DomainObject::oilsMethod', type => 'hash');
5
6 sub toString {
7         my $self = shift;
8         return OpenSRF::Utils::JSON->perl2JSON($self);
9 }
10
11 sub new {
12         my $self = shift;
13         my $class = ref($self) || $self;
14         my %args = @_;
15         return bless \%args => $class;
16 }
17
18
19 =head1 NAME
20
21 OpenSRF::DomainObject::oilsMethod
22
23 =head1 SYNOPSIS
24
25 use OpenSRF::DomainObject::oilsMethod;
26
27 my $method = OpenSRF::DomainObject::oilsMethod->new( method => 'search' );
28
29 $method->return_type( 'mods' );
30
31 $method->params( 'title:harry potter' );
32
33 $client->send( 'REQUEST', $method );
34
35 =head1 METHODS
36
37 =head2 OpenSRF::DomainObject::oilsMethod->method( [$new_method_name] )
38
39 =over 4
40
41 Sets or gets the method name that will be called on the server.  As above,
42 this can be specified as a build attribute as well as added to a prebuilt
43 oilsMethod object.
44
45 =back
46
47 =cut
48
49 sub method {
50         my $self = shift;
51         my $val = shift;
52         $self->{method} = $val if (defined $val);
53         return $self->{method};
54 }
55
56 =head2 OpenSRF::DomainObject::oilsMethod->return_type( [$new_return_type] )
57
58 =over 4
59
60 Sets or gets the return type for this method call.  This can also be supplied as
61 a build attribute.
62
63 This option does not require that the server return the type you request.  It is
64 used as a suggestion when more than one return type or format is possible.
65
66 =back
67
68 =cut
69
70
71 sub return_type {
72         my $self = shift;
73         my $val = shift;
74         $self->{return_type} = $val if (defined $val);
75         return $self->{return_type};
76 }
77
78 =head2 OpenSRF::DomainObject::oilsMethod->params( @new_params )
79
80 =over 4
81
82 Sets or gets the parameters for this method call.  Just pass in either text
83 parameters, or DOM nodes of any type.
84
85 =back
86
87 =cut
88
89
90 sub params {
91         my $self = shift;
92         my @args = @_;
93         $self->{params} = \@args if (@args);
94         if ($self->{params}) {
95                 return @{ $self->{params} };
96         } else {
97                 return ();
98         }
99 }
100
101 1;