File: HasDecoder.pm

package info (click to toggle)
libmaxmind-db-reader-perl 1.000014-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,040 kB
  • sloc: perl: 1,668; makefile: 10
file content (38 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package MaxMind::DB::Reader::Role::HasDecoder;

use strict;
use warnings;
use namespace::autoclean;

our $VERSION = '1.000014';

use MaxMind::DB::Common qw( DATA_SECTION_SEPARATOR_SIZE );
use MaxMind::DB::Reader::Decoder;
use MaxMind::DB::Types qw( Decoder );

use Moo::Role;

with 'MaxMind::DB::Role::Debugs';

# Can't require accessors :(
# requires 'data_source', '_search_tree_size';

has _decoder => (
    is       => 'ro',
    isa      => Decoder,
    init_arg => undef,
    lazy     => 1,
    builder  => '_build_decoder',
);

sub _build_decoder {
    my $self = shift;

    return MaxMind::DB::Reader::Decoder->new(
        data_source  => $self->data_source,
        pointer_base => $self->_search_tree_size
            + DATA_SECTION_SEPARATOR_SIZE,
    );
}

1;