From: Florian Ragwitz Date: Fri, 10 Apr 2009 01:02:54 +0000 (+0200) Subject: use style; X-Git-Tag: 0.17~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=56803befb2535cf73f725541c2c439fee8a92f86;p=gitmo%2FMooseX-AttributeHelpers.git use style; Fix some style issues related to the previous patch. Mostly trailing whitespace. --- diff --git a/lib/MooseX/AttributeHelpers/Collection/Hash.pm b/lib/MooseX/AttributeHelpers/Collection/Hash.pm index a7ae349..c68d1ad 100644 --- a/lib/MooseX/AttributeHelpers/Collection/Hash.pm +++ b/lib/MooseX/AttributeHelpers/Collection/Hash.pm @@ -39,7 +39,7 @@ MooseX::AttributeHelpers::Collection::Hash package Stuff; use Moose; use MooseX::AttributeHelpers; - + has 'options' => ( metaclass => 'Collection::Hash', is => 'ro', @@ -47,16 +47,16 @@ MooseX::AttributeHelpers::Collection::Hash default => sub { {} }, provides => { 'set' => 'set_option', - 'get' => 'get_option', + 'get' => 'get_option', 'empty' => 'has_options', 'count' => 'num_options', 'delete' => 'delete_option', } ); - + =head1 DESCRIPTION -This module provides a Hash attribute which provides a number of +This module provides a Hash attribute which provides a number of hash-like operations. See L for more details. @@ -76,7 +76,7 @@ for more details. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. diff --git a/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm b/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm index 36484e0..c8253ff 100644 --- a/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm +++ b/lib/MooseX/AttributeHelpers/MethodProvider/ImmutableHash.pm @@ -6,17 +6,17 @@ $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; sub exists : method { - my ($attr, $reader, $writer) = @_; + my ($attr, $reader, $writer) = @_; return sub { CORE::exists $reader->($_[0])->{$_[1]} ? 1 : 0 }; -} +} sub defined : method { - my ($attr, $reader, $writer) = @_; + my ($attr, $reader, $writer) = @_; return sub { CORE::defined $reader->($_[0])->{$_[1]} ? 1 : 0 }; -} +} sub get : method { - my ($attr, $reader, $writer) = @_; + my ($attr, $reader, $writer) = @_; return sub { if ( @_ == 2 ) { $reader->($_[0])->{$_[1]} @@ -29,32 +29,32 @@ sub get : method { sub keys : method { my ($attr, $reader, $writer) = @_; - return sub { CORE::keys %{$reader->($_[0])} }; + return sub { CORE::keys %{$reader->($_[0])} }; } - + sub values : method { my ($attr, $reader, $writer) = @_; - return sub { CORE::values %{$reader->($_[0])} }; -} + return sub { CORE::values %{$reader->($_[0])} }; +} sub kv : method { my ($attr, $reader, $writer) = @_; - return sub { + return sub { my $h = $reader->($_[0]); map { [ $_, $h->{$_} ] - } CORE::keys %{$h} - }; + } CORE::keys %{$h} + }; } - + sub count : method { my ($attr, $reader, $writer) = @_; - return sub { scalar CORE::keys %{$reader->($_[0])} }; + return sub { scalar CORE::keys %{$reader->($_[0])} }; } sub empty : method { my ($attr, $reader, $writer) = @_; - return sub { scalar CORE::keys %{$reader->($_[0])} ? 1 : 0 }; + return sub { scalar CORE::keys %{$reader->($_[0])} ? 1 : 0 }; } 1; @@ -66,10 +66,10 @@ __END__ =head1 NAME MooseX::AttributeHelpers::MethodProvider::ImmutableHash - + =head1 DESCRIPTION -This is a role which provides the method generators for +This is a role which provides the method generators for L. =head1 METHODS @@ -102,7 +102,7 @@ L. =head1 BUGS -All complex software has bugs lurking in it, and this module is no +All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. diff --git a/t/003_basic_hash.t b/t/003_basic_hash.t index b9dfbc0..e32c830 100644 --- a/t/003_basic_hash.t +++ b/t/003_basic_hash.t @@ -7,7 +7,7 @@ use Test::More tests => 42; use Test::Exception; BEGIN { - use_ok('MooseX::AttributeHelpers'); + use_ok('MooseX::AttributeHelpers'); } { @@ -22,13 +22,13 @@ BEGIN { default => sub { {} }, provides => { 'set' => 'set_option', - 'get' => 'get_option', + 'get' => 'get_option', 'empty' => 'has_options', 'count' => 'num_options', 'clear' => 'clear_options', 'delete' => 'delete_option', 'exists' => 'has_option', - 'defined'=> 'is_defined' + 'defined'=> 'is_defined', }, curries => { 'set' => { @@ -132,14 +132,14 @@ my $options = $stuff->meta->get_attribute('options'); isa_ok($options, 'MooseX::AttributeHelpers::Collection::Hash'); is_deeply($options->provides, { - 'set' => 'set_option', - 'get' => 'get_option', - 'empty' => 'has_options', - 'count' => 'num_options', - 'clear' => 'clear_options', - 'delete' => 'delete_option', - 'defined'=> 'is_defined', - 'exists' => 'has_option', + 'set' => 'set_option', + 'get' => 'get_option', + 'empty' => 'has_options', + 'count' => 'num_options', + 'clear' => 'clear_options', + 'delete' => 'delete_option', + 'defined' => 'is_defined', + 'exists' => 'has_option', }, '... got the right provies mapping'); is($options->type_constraint->type_parameter, 'Str', '... got the right container type');