| 1 | package WWW::BigDoor::URL; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 3 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | #use Smart::Comments -ENV; | ||||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | use base qw(WWW::BigDoor::Resource Class::Accessor); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 3 | __PACKAGE__->follow_best_practice; | |||||||||
| 12 | 3 | __PACKAGE__->mk_accessors( qw(id read_only url attributes is_for_end_user_ui is_media_url) ); | |||||||||
| 13 | |||||||||||
| 14 | # FIXME DRY with Attribute | ||||||||||
| 15 | 1 | ▶ | sub associate_with { | ||||||||
|
Subroutine
associate_with: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||
| 16 | 1 | my ( $self, $resource, $client ) = @_; | |||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | unless ( defined $self->get_id ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | croak 'URL should have ID - save before associating'; | |||||||||
| 20 | } | ||||||||||
| 21 | 1 | ▶ | unless ( defined $resource->get_id ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 0 | croak 'Object should have ID - save before associating'; | |||||||||
| 23 | } | ||||||||||
| 24 | 1 | my $ep = $self->_end_point; | |||||||||
| 25 | |||||||||||
| 26 | 1 | my $result = $client->POST( | |||||||||
| 27 | sprintf( '%s/%s/%s/%s', | ||||||||||
| 28 | $ep, $self->get_id, $resource->get_resource_name, | ||||||||||
| 29 | $resource->get_id ), | ||||||||||
| 30 | {format => 'json'} | ||||||||||
| 31 | ); | ||||||||||
| 32 | 1 | return $result; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 3 | 1; | |||||||||
| 36 | __END__ | ||||||||||