Commits

Shlomi Fish committed 1b31b50

Convert to a class method.

Comments (0)

Files changed (2)

bin/extract-fortune-data.pl

 
 my @fields = ( qw(page_title meta_desc about_blurb) );
 
-foreach my $r (@{Shlomif::Homepage::FortuneCollections::sorted_fortunes() })
+foreach my $r (@{Shlomif::Homepage::FortuneCollections->sorted_fortunes() })
 {
     my $id = $r->id();
 

lib/Shlomif/Homepage/FortuneCollections.pm

 
 sub _init_fortune
 {
-    my $rec = shift;
+    my ($class, $rec) = @_;
 
     foreach my $req_field (@req_fields)
     {
 
 my @forts =
 (
-    map { _init_fortune($_) } @$orig_fortunes_records,
+    map { __PACKAGE__->_init_fortune($_) } @$orig_fortunes_records,
 );
 
 sub get_fortune_records
 {
+    my ($class) = @_;
+
     return \@forts;
 }
 
 sub sorted_fortunes
 {
+    my ($class) = @_;
+
     return
     [
         sort { $a->id() cmp $b->id() }
-        @{get_fortune_records()}
+        @{$class->get_fortune_records()}
     ];
 }
 
 sub nav_data
 {
-    return [ map { $_->nav_record() } @{sorted_fortunes()} ] ;
+    my ($class) = @_;
+
+    return [ map { $_->nav_record() } @{$class->sorted_fortunes()} ] ;
 }
 
 sub print_single_fortune_record_toc_entry
     my ($class) = @_;
 
 
-    foreach my $r (@{Shlomif::Homepage::FortuneCollections::sorted_fortunes() })
+    foreach my $r (@{Shlomif::Homepage::FortuneCollections->sorted_fortunes() })
     {
         my $path = "t2/humour/fortunes/@{[$r->id()]}.html.wml";
         $class->_print_if_update_needed(