Skip to content

Commit

Permalink
updated to use namespace::autoclean, immutable, and specifiy requirem…
Browse files Browse the repository at this point in the history
…ent for moosex::classattribute
  • Loading branch information
EvanCarroll committed Sep 20, 2010
1 parent d10d3f8 commit a71ea8b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
5 changes: 5 additions & 0 deletions 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.

4 changes: 2 additions & 2 deletions Makefile.PL
Expand Up @@ -6,8 +6,8 @@ author 'Evan Carroll <me+cpan@evancarroll.com>';
license 'perl';

requires 'Moose';
requires 'MooseX::AttributeHelpers';
requires 'MooseX::ClassAttribute';
requires 'MooseX::ClassAttribute' => '0.16';
requires 'namespace::autoclean';

test_requires 'Test::More';

Expand Down
24 changes: 18 additions & 6 deletions lib/Olson/Abbreviations.pm
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -145,6 +155,8 @@ sub get_offset {
$self->_get( $self->tz_abbreviation );
}

__PACKAGE__->meta->make_immutable;

1;

__END__
Expand Down

0 comments on commit a71ea8b

Please sign in to comment.