| 1 | # A class representing a flights response from the OpenSky Network API | ||
| 2 | |||
| 3 | package OpenSky::API::Flights; | ||
| 4 | |||
| 5 | 5 | our $VERSION = '0.005'; | |
| 6 | 5 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 5 | ▶ | use OpenSky::API::Types qw(InstanceOf); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 5 | ▶ | use OpenSky::API::Core::Flight; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 5 | ▶ | use OpenSky::API::Utils::Iterator; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 5 | ▶ | use experimental qw(signatures); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 5 | has flights => ( | |
| 13 | is => 'ro', | ||
| 14 | isa => InstanceOf ['OpenSky::API::Utils::Iterator'], | ||
| 15 | handles => [qw(first next reset all count)], | ||
| 16 | ); | ||
| 17 | |||
| 18 | 0 | ▶ | around 'BUILDARGS' => sub ( $orig, $class, $response ) { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 19 | 0 | my @flights = map { OpenSky::API::Core::Flight->new($_) } $response->@*; | |
| 20 | 0 | my $iterator = OpenSky::API::Utils::Iterator->new( rows => \@flights ); | |
| 21 | |||
| 22 | 0 | return $class->$orig( flights => $iterator ); | |
| 23 | 5 | }; | |
| 24 | |||
| 25 | 5 | __PACKAGE__->meta->make_immutable; | |
| 26 | |||
| 27 | __END__ | ||