Add each_value to scalar. Also add tests for the behaviour of setting both $_ and...
[gitmo/Moose-Autobox.git] / lib / Moose / Autobox / Scalar.pm
1 package Moose::Autobox::Scalar;
2 use Moose::Role 'with';
3
4 our $VERSION = '0.10';
5
6 with 'Moose::Autobox::String',
7      'Moose::Autobox::Number';     
8
9 sub flatten { $_[0] }
10 sub first { $_[0] }
11 sub last  { $_[0] }
12 sub print { CORE::print $_[0] }
13 sub say   { CORE::print $_[0], "\n" }
14 sub each_value { $_[1]->($_ = $_[0]) }
15
16 1;
17
18 __END__
19
20 =pod
21
22 =head1 NAME 
23
24 Moose::Autobox::Scalar - the Scalar role
25
26 =head1 DESCRIPTION
27
28 This is a role to describes a Scalar value, which is defined 
29 as the combination (union sort of) of a String and a Number.
30
31 =head1 METHODS
32
33 =over 4
34
35 =item B<meta>
36
37 =item B<print>
38
39 =item B<say>
40
41 =item B<flatten>
42
43 Flattening a scalar just returns the scalar.  This means that you can say:
44
45   my @array = $input->flatten;
46
47   # Given $input of 5, @array is (5);
48   # Given $input of [ 5, 2, 0], @array is (5, 2, 0)
49
50 =back
51
52 =item B<first>
53
54 As per flatten.
55
56 =item B<last>
57
58 As per flatten.
59
60 =item B<each_value>
61
62 As per flatten.
63
64 =head1 BUGS
65
66 All complex software has bugs lurking in it, and this module is no 
67 exception. If you find a bug please either email me, or add the bug
68 to cpan-RT.
69
70 =head1 AUTHOR
71
72 Stevan Little E<lt>stevan@iinteractive.comE<gt>
73
74 =head1 COPYRIGHT AND LICENSE
75
76 Copyright 2006-2008 by Infinity Interactive, Inc.
77
78 L<http://www.iinteractive.com>
79
80 This library is free software; you can redistribute it and/or modify
81 it under the same terms as Perl itself.
82
83 =cut