[Rt-commit] r19960 - rt/3.999/trunk/lib/RT/Lorzy/Package
clkao at bestpractical.com
clkao at bestpractical.com
Wed Jun 10 10:37:04 EDT 2009
Author: clkao
Date: Wed Jun 10 10:37:03 2009
New Revision: 19960
Modified:
rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm
Log:
implement Condition.BeforeDue
Modified: rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm
==============================================================================
--- rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm (original)
+++ rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm Wed Jun 10 10:37:03 2009
@@ -85,35 +85,34 @@
},
);
-__PACKAGE__->defun( 'Condition.BeforeDue', # XXX: lambday required, doesn't work yet
- signature => $sig_ticket_txn,
- native => sub {
- my $args = shift;
+__PACKAGE__->defun( 'Condition.BeforeDue',
+ # format is "1d2h3m4s" for 1 day and 2 hours and 3 minutes and 4 seconds.
+ signature => { 'datestring' => Lorzy::FunctionArgument->new( name => 'datestring', type => 'Str' ) },
- # Parse date string. format is "1d2h3m4s" for 1 day and 2 hours
- # and 3 minutes and 4 seconds.
+ native => sub {
+ my $xargs = shift;
my %e;
foreach (qw(d h m s)) {
- my @vals = $args->{argument} =~ m/(\d+)$_/;
+ my @vals = $xargs->{datestring} =~ m/(\d+)$_/;
$e{$_} = pop @vals || 0;
}
my $elapse = $e{'d'} * 24 * 60 * 60 + $e{'h'} * 60 * 60 + $e{'m'} * 60 + $e{'s'};
- my $cur = RT::DateTime->now;
- my $due = $args->{ticket}->due;
- return (undef) if $due->epoch <= 0;
-
- my $diff = $due->diff($cur);
- if ( $diff >= 0 and $diff <= $elapse ) {
- return (1);
- } else {
- return (undef);
- }
+ return Lorzy::Lambda::Native->new
+ ( body => sub {
+ my $args = shift;
+ my $cur = RT::DateTime->now;
+ my $due = $args->{ticket}->due;
+ return (undef) if $due->epoch <= 0;
+ my $diff = $due->diff($cur);
+ return ($diff >= 0 and $diff <= $elapse);
+ },
+ signature => $sig_ticket_txn );
},
);
-__PACKAGE__->defun( 'Condition.PriorityExceeds', # XXX: lambday required, doesn't work yet
+__PACKAGE__->defun( 'Condition.PriorityExceeds',
signature => { 'priority' => Lorzy::FunctionArgument->new( name => 'priority', type => 'Int' ),
},
native => sub {
More information about the Rt-commit
mailing list