Mercurial > pub > Impl
comparison Lib/IMPL/Web/AutoLocator.pm @ 326:793cc7f0a7e7
IMPL::Web::AutoLocator added Sibling method for locating sibling resources
| author | sergey |
|---|---|
| date | Wed, 29 May 2013 17:58:45 +0400 |
| parents | 6dc1c369eb71 |
| children | 7171a8e2e2ba |
comparison
equal
deleted
inserted
replaced
| 325:34a110d1f06c | 326:793cc7f0a7e7 |
|---|---|
| 53 } | 53 } |
| 54 | 54 |
| 55 return $this->new(%args); | 55 return $this->new(%args); |
| 56 } | 56 } |
| 57 | 57 |
| 58 sub Sibling { | |
| 59 my $this = shift; | |
| 60 my $child = shift or die ArgumentException->new("a child resource identifier is required"); | |
| 61 die ArgumentException->new("a child resource can't be a reference") if ref $child; | |
| 62 | |
| 63 # safe | |
| 64 $child = uri_escape($child); | |
| 65 | |
| 66 my %args; | |
| 67 | |
| 68 if($this->base =~ /(.*?)(\/[^\/]*)?$/) { | |
| 69 $args{base} = join('/',$1,$child); | |
| 70 } else { | |
| 71 $args{base} = $child; | |
| 72 } | |
| 73 | |
| 74 $args{view} = $this->view if $this->view; | |
| 75 $args{hash} = $this->hash if $this->hash; | |
| 76 | |
| 77 if (@_) { | |
| 78 my $query = shift; | |
| 79 | |
| 80 $args{query} = ref $query eq 'HASH' ? hashMerge($this->query,$query) : $query; | |
| 81 } | |
| 82 | |
| 83 return $this->new(%args); | |
| 84 | |
| 85 } | |
| 86 | |
| 58 sub Query { | 87 sub Query { |
| 59 my ($this,$query) = @_; | 88 my ($this,$query) = @_; |
| 60 | 89 |
| 61 my %args; | 90 my %args; |
| 62 | 91 |
