[Rt-commit] r5636 - in Object-Declare: lib/Object t
audreyt at bestpractical.com
audreyt at bestpractical.com
Fri Jul 21 00:23:00 EDT 2006
Author: audreyt
Date: Fri Jul 21 00:23:00 2006
New Revision: 5636
Modified:
Object-Declare/Changes
Object-Declare/lib/Object/Declare.pm
Object-Declare/t/01-basic.t
Log:
* This be 0.11.
* Support the prefix ! operator on declarations, so negated ones
such as "!is global" or "!global is $x" now work.
Requested by: Jesse Vincent
Modified: Object-Declare/Changes
==============================================================================
--- Object-Declare/Changes (original)
+++ Object-Declare/Changes Fri Jul 21 00:23:00 2006
@@ -1,3 +1,9 @@
+[Changes for 0.11 - 2006-07-20]
+
+* Support the prefix ! operator on declarations, so negated ones
+ such as "!is global" or "!global is $x" now work.
+ Requested by: Jesse Vincent
+
[Changes for 0.10 - 2006-07-20]
* The "copula" interface now accepts an arbitrary prefix for each
Modified: Object-Declare/lib/Object/Declare.pm
==============================================================================
--- Object-Declare/lib/Object/Declare.pm (original)
+++ Object-Declare/lib/Object/Declare.pm Fri Jul 21 00:23:00 2006
@@ -4,7 +4,7 @@
use strict;
use warnings;
-$Object::Declare::VERSION = '0.10';
+$Object::Declare::VERSION = '0.11';
use Sub::Override;
@@ -15,7 +15,7 @@
my $mapping = $args{mapping} or return;
my $declarator = $args{declarator} || ['declare'];
- my $copula = $args{copula} || ['is', 'are'];
+ my $copula = $args{copula} || ['is', 'are', 'isn::t'];
# Both declarator and copula can contain more than one entries;
# normalize into an arrayref if we only have on entry.
@@ -136,6 +136,14 @@
package Object::Declare::Katamari;
+use overload "!" => \&negation;
+
+sub negation {
+ my @katamari = @{$_[0]} or return ();
+ $katamari[1] = !$katamari[1];
+ return bless(\@katamari, ref($_[0]));
+}
+
# Unroll a Katamari structure into constructor arguments.
sub unroll {
my @katamari = @{$_[0]} or return ();
@@ -170,6 +178,7 @@
my %objects = declare {
param foo =>
+ !is global,
is immutable,
valid_values are qw( more values );
Modified: Object-Declare/t/01-basic.t
==============================================================================
--- Object-Declare/t/01-basic.t (original)
+++ Object-Declare/t/01-basic.t Fri Jul 21 00:23:00 2006
@@ -21,6 +21,7 @@
is field3;
alt_col y =>
+ !is happy,
field1 is 'yyy',
field2 is 'YYY';
} }
@@ -39,6 +40,7 @@
'field1' => 'yyy',
'field2' => 'YYY',
'alt' => 1,
+ happy => '',
},
], 'object declared correctly (list context)');
@@ -56,6 +58,7 @@
'field1' => 'yyy',
'field2' => 'YYY',
'alt' => 1,
+ happy => '',
},
}, 'object declared correctly (scalar context)');
More information about the Rt-commit
mailing list