Permalink
Browse files

adding documentation slot to the attributes

  • Loading branch information...
1 parent 900466d commit ddbdc0cbd3483afc38ce175c9d5694a0a6ed0b8f Stevan Little committed Mar 29, 2007
Showing with 63 additions and 10 deletions.
  1. +19 −6 Changes
  2. +16 −2 lib/Moose/Meta/Attribute.pm
  3. +25 −1 t/071_misc_attribute_tests.t
  4. +3 −1 t/202_example_Moose_POOP.t
View
25 Changes
@@ -3,7 +3,7 @@ Revision history for Perl extension Moose
0.19
* Moose::Util::TypeConstraints
- type now supports messages as well
- (thanks to phaylon for finding this)
+ thanks to phaylon for finding this
- added tests for this
- added list_all_type_constraints and
list_all_builtin_type_constraints
@@ -13,21 +13,34 @@ Revision history for Perl extension Moose
- fixed regexp 'handles' declarations
to build the list of delegated methods
correctly (and not override important
- things like &new)
+ things like &new) thanks to ashleyb
+ for finding this
+ - added tests and docs for this
+ - added the "documentation" attributes
+ so that you can actually document your
+ attributes and inspect them through the
+ meta-object.
- added tests and docs for this
* Moose::Meta::TypeConstraint
- type constraints now stringify to their names.
- added test for this
* misc.
- - added test for working with Module::Refresh
+ - added tests to assure we work with Module::Refresh
+ - added stricter test skip logic in the Moose POOP
+ test, ask Rob Kinyon why.
+ - *cough* DBM::Deep 1.0 backwards compatability sucks *cough* ;)
0.18 Sat. March 10, 2007
~~ Many, many documentation updates ~~
-
- - We now use Class::MOP::load_class to
- load all classes.
+
+ * misc.
+ - We now use Class::MOP::load_class to
+ load all classes.
+ - added tests to show types and subtypes
+ working with Declare::Constraints::Simple
+ and Test::Deep as constraint engines.
0.18_001
!! You must have Class::MOP 0.37_001 !!
@@ -39,6 +39,10 @@ __PACKAGE__->meta->add_attribute('handles' => (
reader => 'handles',
predicate => 'has_handles',
));
+__PACKAGE__->meta->add_attribute('documentation' => (
+ reader => 'documentation',
+ predicate => 'has_documentation',
+));
sub new {
my ($class, $name, %options) = @_;
@@ -48,9 +52,9 @@ sub new {
sub clone_and_inherit_options {
my ($self, %options) = @_;
- # you can change default, required and coerce
+ # you can change default, required, coerce and documentation
my %actual_options;
- foreach my $legal_option (qw(default coerce required)) {
+ foreach my $legal_option (qw(default coerce required documentation)) {
if (exists $options{$legal_option}) {
$actual_options{$legal_option} = $options{$legal_option};
delete $options{$legal_option};
@@ -541,6 +545,16 @@ value of an attribute is assigned. The CODE ref will get two values,
the invocant and the new value. This can be used to handle I<basic>
bi-directional relations.
+=item B<documentation>
+
+This is a string which contains the documentation for this attribute.
+It serves no direct purpose right now, but it might in the future
+in some kind of automated documentation system perhaps.
+
+=item B<has_documentation>
+
+Returns true if this meta-attribute has any documentation.
+
=back
=head1 BUGS
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 6;
use Test::Exception;
BEGIN {
@@ -12,6 +12,30 @@ BEGIN {
{
{
+ package Test::Attribute::Inline::Documentation;
+ use Moose;
+
+ has 'foo' => (
+ documentation => q{
+ The 'foo' attribute is my favorite
+ attribute in the whole wide world.
+ }
+ );
+ }
+
+ my $foo_attr = Test::Attribute::Inline::Documentation->meta->get_attribute('foo');
+
+ ok($foo_attr->has_documentation, '... the foo has docs');
+ is($foo_attr->documentation,
+ q{
+ The 'foo' attribute is my favorite
+ attribute in the whole wide world.
+ },
+ '... got the foo docs');
+}
+
+{
+ {
package Test::For::Lazy::TypeConstraint;
use Moose;
use Moose::Util::TypeConstraints;
@@ -7,7 +7,9 @@ use Test::More;
BEGIN {
eval "use DBM::Deep 0.983; use DateTime::Format::MySQL;";
- plan skip_all => "DBM::Deep and DateTime::Format::MySQL required for this test" if $@;
+ if ($@ && DBM::Deep->VERSION < 1.0) {
+ plan skip_all => "DBM::Deep (< 1.0) and DateTime::Format::MySQL required for this test";
+ }
plan tests => 89;
}

0 comments on commit ddbdc0c

Please sign in to comment.