Subject: | Fix for recipe 5, other small changes to recipes |
In recipe 5 class_type('HTTP::Headers') is used for attributes of type
URI. The patch fixes that and adds tests for that. Thank you!
Subject: | Moose-0.72-docs.patch |
diff -Naur Moose-0.72.orig/lib/Moose/Cookbook/Basics/Recipe11.pod Moose-0.72/lib/Moose/Cookbook/Basics/Recipe11.pod
--- Moose-0.72.orig/lib/Moose/Cookbook/Basics/Recipe11.pod 2009-02-19 16:35:01.000000000 +0200
+++ Moose-0.72/lib/Moose/Cookbook/Basics/Recipe11.pod 2009-03-05 17:59:40.000000000 +0200
@@ -89,7 +89,7 @@
before it is returned to the caller. The C<BUILD> method provides an
opportunity to check the object state as a whole. This is a good place
to put logic that cannot be expressed as a type constraint on a single
-object.
+attribute.
In the C<Person> class, we need to check the relationship between two
attributes, C<ssn> and C<country_of_residence>. We throw an exception
diff -Naur Moose-0.72.orig/lib/Moose/Cookbook/Basics/Recipe5.pod Moose-0.72/lib/Moose/Cookbook/Basics/Recipe5.pod
--- Moose-0.72.orig/lib/Moose/Cookbook/Basics/Recipe5.pod 2009-02-22 18:24:55.000000000 +0200
+++ Moose-0.72/lib/Moose/Cookbook/Basics/Recipe5.pod 2009-03-05 17:58:12.000000000 +0200
@@ -36,7 +36,7 @@
=> from 'HashRef'
=> via { HTTP::Headers->new( %{$_} ) };
- subtype 'My.URI' => as class_type('HTTP::Headers');
+ subtype 'My.URI' => as class_type('URI');
coerce 'My.URI'
=> from 'Object'
@@ -150,7 +150,7 @@
Once again, we need to declare a class type for our non-Moose L<URI>
class:
- subtype 'My.URI' => as class_type('HTTP::Headers');
+ subtype 'My.URI' => as class_type('URI');
Then we define the coercion:
diff -Naur Moose-0.72.orig/lib/Moose/Cookbook/Roles/Recipe1.pod Moose-0.72/lib/Moose/Cookbook/Roles/Recipe1.pod
--- Moose-0.72.orig/lib/Moose/Cookbook/Roles/Recipe1.pod 2009-02-19 16:35:04.000000000 +0200
+++ Moose-0.72/lib/Moose/Cookbook/Roles/Recipe1.pod 2009-03-05 18:01:11.000000000 +0200
@@ -78,7 +78,7 @@
comparison and display code for objects.
Let's start with C<Eq>. First, note that we've replaced C<use Moose>
-with C<use Moose::Role>. We also have a new sugar function, C<required>:
+with C<use Moose::Role>. We also have a new sugar function, C<requires>:
requires 'equal_to';
diff -Naur Moose-0.72.orig/t/000_recipes/moose_cookbook_basics_recipe5.t Moose-0.72/t/000_recipes/moose_cookbook_basics_recipe5.t
--- Moose-0.72.orig/t/000_recipes/moose_cookbook_basics_recipe5.t 2009-02-24 06:47:25.000000000 +0200
+++ Moose-0.72/t/000_recipes/moose_cookbook_basics_recipe5.t 2009-03-05 17:57:10.000000000 +0200
@@ -38,7 +38,7 @@
=> from 'HashRef'
=> via { HTTP::Headers->new( %{$_} ) };
- subtype 'My.URI' => as class_type('HTTP::Headers');
+ subtype 'My.URI' => as class_type('URI');
coerce 'My.URI'
=> from 'Object'
@@ -125,6 +125,15 @@
}
'... the protocol died with bar params correctly';
}
+
+{
+ $r->base('http://localhost/');
+ isa_ok( $r->base, 'URI' );
+
+ $r->uri('http://localhost/');
+ isa_ok( $r->uri, 'URI' );
+}
+
}