[Bps-public-commit] UNNAMED PROJECT branch, master, updated. 8d11921df6790e28d6e63162740bd1ad38a42372

jesse jesse at bestpractical.com
Thu Jan 15 23:26:07 EST 2009


The branch, master has been updated
       via  8d11921df6790e28d6e63162740bd1ad38a42372 (commit)
      from  7850dbb1101cbc89a580d9cc3d5363f0cb630e4e (commit)

Summary of changes:
 lib/App/SD/Model/Ticket.pm |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 8d11921df6790e28d6e63162740bd1ad38a42372
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jan 15 23:24:02 2009 -0500

    Cache the list of acceptable statuses in memory the first time we look
    at it
    
    TODO: clear the cache when editing configuration

diff --git a/lib/App/SD/Model/Ticket.pm b/lib/App/SD/Model/Ticket.pm
index d46fc1e..ee44572 100644
--- a/lib/App/SD/Model/Ticket.pm
+++ b/lib/App/SD/Model/Ticket.pm
@@ -7,9 +7,16 @@ use HTTP::Date;
 
 use constant collection_class => 'App::SD::Collection::Ticket';
 has type => ( default => 'ticket');
+
+our $ACTIVE_STATUSES;
+
 __PACKAGE__->register_reference( comments => 'App::SD::Collection::Comment', by => 'ticket');
 __PACKAGE__->register_reference( attachments => 'App::SD::Collection::Attachment', by => 'ticket');
 
+sub BUILD {
+    my $self = shift;
+    $ACTIVE_STATUSES ||= $self->app_handle->setting(label => 'active_statuses')->get();
+}
 
 
 sub default_prop_component { 
@@ -35,7 +42,7 @@ sub default_prop_status {
 
 sub has_active_status {
     my $self = shift;
-    return 1 if grep { $_ eq $self->prop('status') } @{$self->app_handle->setting(label => 'active_statuses')->get()};
+    return 1 if grep { $_ eq $self->prop('status') } @{$ACTIVE_STATUSES};
 }
 
 =head2 default_prop_reporter

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list