From a71ea8b3183d172c785fa25b74a1b7ec22b2cc1e Mon Sep 17 00:00:00 2001 From: Evan Carroll Date: Mon, 20 Sep 2010 17:05:26 -0500 Subject: [PATCH] updated to use namespace::autoclean, immutable, and specifiy requirement for moosex::classattribute --- Changes | 5 +++++ Makefile.PL | 4 ++-- lib/Olson/Abbreviations.pm | 24 ++++++++++++++++++------ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index b941322..d1d4cff 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Olson-Abbreviations +0.02 2010-09-20 + uses namespace clean + removes requirement for MX:AH + specifies version of ClassAttribute required + 0.01 Date/time First version, released on an unsuspecting world. diff --git a/Makefile.PL b/Makefile.PL index 57e4e7c..fdcb0e2 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -6,8 +6,8 @@ author 'Evan Carroll '; license 'perl'; requires 'Moose'; -requires 'MooseX::AttributeHelpers'; -requires 'MooseX::ClassAttribute'; +requires 'MooseX::ClassAttribute' => '0.16'; +requires 'namespace::autoclean'; test_requires 'Test::More'; diff --git a/lib/Olson/Abbreviations.pm b/lib/Olson/Abbreviations.pm index 5373c5c..9720f08 100644 --- a/lib/Olson/Abbreviations.pm +++ b/lib/Olson/Abbreviations.pm @@ -4,14 +4,19 @@ use warnings; use strict; use MooseX::ClassAttribute; -use MooseX::AttributeHelpers; -our $VERSION = '0.01'; +use namespace::autoclean; + +our $VERSION = '0.02'; class_has 'ZONEMAP' => ( - isa => 'HashRef[Maybe[Str]]' + isa => 'HashRef[Str]' , is => 'rw' - , metaclass => 'Collection::Hash' - , provides => { exists => 'is_known', get => '_get' } + , traits => ['Hash'] + , handles => { + '_exists' => 'exists' + , '_get' => 'get' + , '_defined' => 'defined' + } , default => sub { # Table for mapping abbreviated timezone names to tz_abbreviations return { @@ -124,9 +129,14 @@ class_has 'ZONEMAP' => ( has 'tz_abbreviation' => ( isa => 'Str', is => 'rw', required => 1 ); +sub is_known { + my $self = shift; + $self->_exists( $self->tz_abbreviation ); +} + sub is_unambigious { my $self = shift; - defined $self->_get->( $self->tz_abbreviation ); + $self->_defined( $self->tz_abbreviation ); } sub get_offset { @@ -145,6 +155,8 @@ sub get_offset { $self->_get( $self->tz_abbreviation ); } +__PACKAGE__->meta->make_immutable; + 1; __END__