| 1 | package Net::OpenSocial::Client::Resource; | ||
| 2 | |||
| 3 | 1 | ▶ | use Any::Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Any::Moose 'X::AttributeHelpers'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | has 'service' => ( | |
| 7 | is => 'ro', | ||
| 8 | isa => 'Str', | ||
| 9 | required => 1, | ||
| 10 | ); | ||
| 11 | |||
| 12 | 1 | has 'version' => ( | |
| 13 | is => 'ro', | ||
| 14 | isa => 'Str', | ||
| 15 | default => q{0.8.1}, | ||
| 16 | required => 1, | ||
| 17 | ); | ||
| 18 | |||
| 19 | has 'fields' => ( | ||
| 20 | is => 'ro', | ||
| 21 | isa => 'HashRef', | ||
| 22 | 0 | ▶ | default => sub { +{} }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 23 | 1 | metaclass => 'Collection::Hash', | |
| 24 | provides => { | ||
| 25 | 'get' => 'get_field', | ||
| 26 | 'set' => 'set_field', | ||
| 27 | 'exists' => 'has_field', | ||
| 28 | 'keys' => 'field_names', | ||
| 29 | }, | ||
| 30 | ); | ||
| 31 | |||
| 32 | 1 | ▶ | no Any::Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | 1 | __PACKAGE__->meta->make_immutable; | |
| 34 | 1 | 1; | |
| 35 | |||
| 36 | =head1 NAME | ||
| 37 | |||
| 38 | Net::OpenSocial::Client::Resource - Resource base class. | ||
| 39 | |||
| 40 | =head1 SYNOPSIS | ||
| 41 | |||
| 42 | package ConcreteResource; | ||
| 43 | use Any::Moose; | ||
| 44 | extends 'Net::OpenSocial::Client::Resource'; | ||
| 45 | ... | ||
| 46 | |||
| 47 | |||
| 48 | my $cr = ConcreteResource->new; | ||
| 49 | $cr->set_field( key1 => 'value1 '); | ||
| 50 | $cr->set_field( key2 => 'value2' ); | ||
| 51 | |||
| 52 | say $cr->get_field( 'key1' ); | ||
| 53 | say $cr->get_field( 'key2' ); | ||
| 54 | |||
| 55 | =head1 DESCRIPTION | ||
| 56 | |||
| 57 | Resource base class. | ||
| 58 | You don't need to use this class directly as long as you dan't | ||
| 59 | develop new opensocial resource class. | ||
| 60 | |||
| 61 | =head1 METHODS | ||
| 62 | |||
| 63 | =head2 service | ||
| 64 | |||
| 65 | Service name of REST/RPC | ||
| 66 | |||
| 67 | =head2 version | ||
| 68 | |||
| 69 | OpenSocial protocol version number. | ||
| 70 | |||
| 71 | =head2 fields | ||
| 72 | |||
| 73 | Hash reference that represents fields of resource. | ||
| 74 | |||
| 75 | =head2 get_field( $key ) | ||
| 76 | |||
| 77 | my $value = $resource->get_field('id'); | ||
| 78 | |||
| 79 | =head2 set_field( $key => $value ) | ||
| 80 | |||
| 81 | $resource->set_field('id' => $resource_id); | ||
| 82 | |||
| 83 | =head2 has_field( $key ) | ||
| 84 | |||
| 85 | if ( $resource->has_field('name') ) { | ||
| 86 | say $resource->get_field('name'); | ||
| 87 | } | ||
| 88 | |||
| 89 | =head2 field_names | ||
| 90 | |||
| 91 | my @names = $resource->field_names(); | ||
| 92 | |||
| 93 | =head1 SEE ALSO | ||
| 94 | |||
| 95 | L<Net::OpenSocial::Client::Resource::Person> | ||
| 96 | L<Net::OpenSocial::Client::Resource::Group> | ||
| 97 | L<Net::OpenSocial::Client::Resource::AppData> | ||
| 98 | L<Net::OpenSocial::Client::Resource::Activity> | ||
| 99 | |||
| 100 | =head1 AUTHOR | ||
| 101 | |||
| 102 | Lyo Kato, E<lt>lyo.kato@gmail.comE<gt> | ||
| 103 | |||
| 104 | =head1 COPYRIGHT AND LICENSE | ||
| 105 | |||
| 106 | Copyright (C) 2009 by Lyo Kato | ||
| 107 | |||
| 108 | This library is free software; you can redistribute it and/or modify | ||
| 109 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||
| 110 | at your option, any later version of Perl 5 you may have available. | ||
| 111 | |||
| 112 | =cut | ||
| 113 | |||