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