The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Elastic::Model::Types - MooseX::Types for general and internal use

VERSION

version 0.02

SYNOPSIS

    use Elastic::Model::Types qw(GeoPoint);

    has 'point' => (
        is      => 'ro',
        isa     => GeoPoint,
        coerce  => 1
    );

DESCRIPTION

Elastic::Model::Types define a number of MooseX::Types, some for internal use and some which will be useful generally.

PUBLIC TYPES

Binary

    use Elastic::Model::Types qw(Binary);

    has 'binary_field' => (
        is  => 'ro',
        isa => Binary
    );

Inherits from the Defined type. Is automatically Base64 encoded/decoded.

GeoPoint

    use Elastic::Model::Types qw(GeoPoint);

    has 'point' => (
        is     => 'ro',
        isa    => GeoPoint,
        coerce => 1,
    );

GeoPoint is a hashref with two keys:

  • lon: a Number between -180 and 180

  • lat: a Number between -90 and 90

It can be coerced from an ArrayRef with [$lon,$lat] and from a Str with "$lat,$lon".

Timestamp

    use Elastic::Model::Types qw(Timestamp);

    has 'timestamp' => (
        is  => 'ro',
        isa => Timestamp
    );

A Timestamp is a Num which holds floating epoch seconds, with milliseconds as decimal places. It is automatically mapped as a date field in ElasticSearch.

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Clinton Gormley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.