From 153621ca159b5aae51e9da6bf5bb8a078405cfaf Mon Sep 17 00:00:00 2001 From: David Golden Date: Wed, 19 Feb 2014 11:01:40 -0500 Subject: [PATCH] perlootut: replace Object::Tiny with Class::Tiny Class::Tiny is similarly small and simple in API, but with more powerful features available. Comparison to Object::Tiny and Class::Accessor is here: https://metacpan.org/pod/Class::Tiny#RATIONALE At mst's suggestion, a link to Class::Tiny::Antlers for Moose-syntax is included. --- pod/perlootut.pod | 24 +++++++++++++----------- t/porting/known_pod_issues.dat | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pod/perlootut.pod b/pod/perlootut.pod index e494f23..a95ecc8 100644 --- a/pod/perlootut.pod +++ b/pod/perlootut.pod @@ -646,17 +646,17 @@ C. Like C, C generates accessor methods and a constructor for your class. -=head2 Object::Tiny +=head2 Class::Tiny -Finally, we have L. This module truly lives up to its +Finally, we have L. This module truly lives up to its name. It has an incredibly minimal API and absolutely no dependencies -(core or not). Still, we think it's a lot easier to use than writing +on any recent Perl. Still, we think it's a lot easier to use than writing your own OO code from scratch. Here's our C class once more: package File; - use Object::Tiny qw( path content last_mod_time ); + use Class::Tiny qw( path content last_mod_time ); sub print_info { my $self = shift; @@ -666,9 +666,11 @@ Here's our C class once more: That's it! -With C, all accessors are read-only. It generates a +With C, all accessors are read-write. It generates a constructor for you, as well as the accessors you define. +You can also use L for C-like syntax. + =head2 Role::Tiny As we mentioned before, roles provide an alternative to inheritance, @@ -681,7 +683,7 @@ C provides some of the same features as Moose's role system, but in a much smaller package. Most notably, it doesn't support any sort of attribute declaration, so you have to do that by hand. Still, it's useful, and works well with C and -C +C =head2 OO System Summary @@ -704,16 +706,16 @@ time and is well battle-tested. It also has a minimal C compatibility mode which makes moving from C to C easy. -=item * L +=item * L -C is the absolute minimal option. It has no dependencies, +C is the absolute minimal option. It has no dependencies, and almost no syntax to learn. It's a good option for a super minimal environment and for throwing something together quickly without having to worry about details. =item * L -Use C with C or C if you +Use C with C or C if you find yourself considering multiple inheritance. If you go with C, it comes with its own role implementation. @@ -737,14 +739,14 @@ OO systems on CPAN. While you can still drop down to the bare metal and write your classes by hand, there's really no reason to do that with modern Perl. -For small systems, L and L both provide +For small systems, L and L both provide minimal object systems that take care of basic boilerplate for you. For bigger projects, L provides a rich set of features that will let you focus on implementing your business logic. We encourage you to play with and evaluate L, -L, and L to see which OO system is right +L, and L to see which OO system is right for you. =cut diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat index 7d74fee..91ecb88 100644 --- a/t/porting/known_pod_issues.dat +++ b/t/porting/known_pod_issues.dat @@ -32,6 +32,8 @@ Class::Accessor Class::C3 Class::ISA Class::PseudoHash +Class::Tiny +Class::Tiny::Antlers Classic::Perl Clone cpan2dist(1) @@ -112,7 +114,6 @@ nl_langinfo(3) Number::Format Object::Accessor Object::InsideOut -Object::Tiny open(2) OS2::Proc OS2::WinObject -- 2.7.4