| 1 | package WebAPI::DBIC::Resource::Role::Set; | ||
| 2 | 25 | $WebAPI::DBIC::Resource::Role::Set::VERSION = '0.004002'; | |
| 3 | |||
| 4 | 25 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | |||
| 7 | 25 | requires 'encode_json'; | |
| 8 | 25 | requires 'render_item_as_plain_hash'; | |
| 9 | |||
| 10 | |||
| 11 | 25 | has content_types_provided => ( | |
| 12 | is => 'lazy', | ||
| 13 | ); | ||
| 14 | |||
| 15 | 74 | ▶ | sub _build_content_types_provided { |
|
Subroutine
_build_content_types_provided: called CC=1 SCAR=0.0
| |||
| 16 | 74 | return [ { 'application/vnd.wapid+json' => 'to_plain_json'} ] | |
| 17 | } | ||
| 18 | |||
| 19 | 16 | ▶ | sub to_plain_json { return $_[0]->encode_json($_[0]->render_set_as_plain($_[0]->set)) } |
|
Subroutine
to_plain_json: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 20 | |||
| 21 | 69 | ▶ | sub allowed_methods { return [ qw(GET HEAD) ] } |
|
Subroutine
allowed_methods: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 22 | |||
| 23 | # Avoid complaints about $set: | ||
| 24 | ## no critic (NamingConventions::ProhibitAmbiguousNames) | ||
| 25 | |||
| 26 | 16 | ▶ | sub render_set_as_plain { |
|
Subroutine
render_set_as_plain: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 27 | 16 | my ($self, $set) = @_; | |
| 28 | 16 | my $set_data = [ map { $self->render_item_as_plain_hash($_) } $set->all ]; | |
| 29 | 16 | return $set_data; | |
| 30 | } | ||
| 31 | |||
| 32 | 25 | 1; | |
| 33 | |||
| 34 | __END__ | ||