| 1 | package Etcd::Response; | ||||||||||
| 2 | 4 | $Etcd::Response::VERSION = '0.003'; | |||||||||
| 3 | 4 | ▶ | use namespace::sweep; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use Etcd::Node; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | ▶ | use JSON qw(decode_json); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 4 | ▶ | use Type::Utils qw(class_type); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 4 | ▶ | use Types::Standard qw(Str Int); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 4 | has action => ( is => 'ro', isa => Str, required => 1 ); | |||||||||
| 14 | 4 | has etcd_index => ( is => 'ro', isa => Int, required => 1 ); | |||||||||
| 15 | 4 | has raft_index => ( is => 'ro', isa => Int, required => 1 ); | |||||||||
| 16 | 4 | has raft_term => ( is => 'ro', isa => Int, required => 1 ); | |||||||||
| 17 | |||||||||||
| 18 | 6 | ▶ | my $node_coercion = sub { ref $_[0] eq 'HASH' ? Etcd::Node->new(%{$_[0]}) : $_[0] }; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||
| 19 | 4 | has node => ( is => 'ro', isa => class_type('Etcd::Node'), coerce => $node_coercion, required => 1 ); | |||||||||
| 20 | 4 | has prev_node => ( is => 'ro', isa => class_type('Etcd::Node'), coerce => $node_coercion, init_arg => 'prevNode' ); | |||||||||
| 21 | |||||||||||
| 22 | sub new_from_http { | ||||||||||
| 23 | 5 | ▶ | my ($class, $res) = @_; | ||||||||
|
Subroutine
new_from_http: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 24 | 5 | my $data = decode_json($res->{content}); | |||||||||
| 25 | 5 | my %headers; | |||||||||
| 26 | 5 | @headers{qw(etcd_index raft_index raft_term)} = @{$res->{headers}}{qw(x-etcd-index x-raft-index x-raft-term)}; | |||||||||
| 27 | 5 | $class->new(%$data, %headers); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 4 | 1; | |||||||||
| 31 | |||||||||||
| 32 | __END__ | ||||||||||