File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11Revision history for Perl module Geo::Address::Formatter.
22
3- 1.9991
3+ 1.9991 2026-02-15
4+ - new instance method for creating singleton and reusing across requests under mod_perl
45
561.9990 2026-02-11
67 - speed optimizations
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ Together we can address the world!
7474
7575 my $GAF = Geo::Address::Formatter->new( conf_path => '/path/to/templates' );
7676
77- Returns one instance . The I<conf_path > is required.
77+ Returns new object . The I<conf_path > is required.
7878
7979Optional parameters are:
8080
@@ -98,6 +98,35 @@ option to L</format_address>.
9898
9999=cut
100100
101+
102+ =head2 instance
103+
104+ my $GAF = Geo::Address::Formatter->instance( conf_path => '/path/to/templates' );
105+
106+ Returns new instance (potentially re-used) The I<conf_path > is required.
107+
108+ Optional parameters are as in the B<new > method.
109+
110+ =cut
111+
112+ my $instance ;
113+
114+ sub instance {
115+ my ($class , %params ) = @_ ;
116+
117+ unless ($instance ) {
118+ $instance = $class -> new(@_ );
119+ }
120+
121+ say STDERR " ************* in Geo::Address::Formatter::instance ***" if ($debug );
122+
123+ # clear these fields that change on each run
124+ $instance -> {final_components } = undef ;
125+ $instance -> {set_district_alias } = {};
126+
127+ return $instance ;
128+ }
129+
101130sub new {
102131 my ($class , %params ) = @_ ;
103132
@@ -117,7 +146,8 @@ sub new {
117146 bless ($self , $class );
118147
119148 say STDERR " ************* in Geo::Address::Formatter::new ***" if ($debug );
120-
149+
150+ # is slow because lots of conf, and pre-compiling
121151 if ($self -> _read_configuration($conf_path )){
122152 return $self ;
123153 }
You can’t perform that action at this time.
0 commit comments