Permalink
Browse files

Forgot to test that last release. Had to use a BEGIN block to get mou…

…se stuff processing. The joys of bundling into one script...
  • Loading branch information...
1 parent 554108d commit f464ed54d9609659947ab1556ac4725fe2dc5e94 James Laver committed Mar 16, 2010
Showing with 29 additions and 17 deletions.
  1. +29 −17 get_iplayer
View
@@ -750,9 +750,9 @@ Options->add_opt_format_object($opt_format);
# Set Programme/Pvr/Streamer class global var refs to the Options instance
History->add_opt_object($opt);
Programme->add_opt_object($opt);
-Pvr->add_opt_object($opt);
-Pvr->add_opt_file_object($opt_file);
-Pvr->add_opt_cmdline_object($opt_cmdline);
+gip::Singletons->pvr->opt($opt);
+gip::Singletons->pvr->opt_file($opt_file);
+gip::Singletons->pvr->opt_cmdline($opt_cmdline);
Streamer->add_opt_object($opt);
# Kludge: Create dummy Streamer, History and Programme instances (without a single instance, none of the bound options work)
@@ -11052,19 +11052,20 @@ sub get {
return 0;
}
+BEGIN {
############# PVR Class ##############
package Pvr;
use File::Path;
use Mouse;
#Instance methods. We are a singleton so need no class vars
-has optref => ( is => 'rw' );
-has opt_fileref => ( is => 'rw' );
-has opt_cmdlineref => ( is => 'rw' );
-has opt => ( is => 'rw' );
-has opt_file => ( is => 'rw' );
-has opt_cmdline => ( is => 'rw' );
+has optref => ( is => 'rw', isa => 'Ref' );
+has opt_fileref => ( is => 'rw', isa => 'Ref' );
+has opt_cmdlineref => ( is => 'rw', isa => 'Ref' );
+has opt => ( is => 'rw', lazy_build => 1, isa => 'Ref');
+has opt_file => ( is => 'rw' , lazy_build => 1, isa => 'Ref');
+has opt_cmdline => ( is => 'rw', lazy_build => 1, isa => 'Ref');
has vars => ( isa => 'HashRef', is => 'rw' );
has searches => (
isa => 'HashRef', is => 'rw', traits => ['Hash'], default => sub{ +{} },
@@ -11074,6 +11075,18 @@ has searches => (
}
);
+sub _build_opt {
+ shift->optref
+}
+
+sub _build_opt_file {
+ shift->opt_fileref
+}
+
+sub _build_opt_cmdline {
+ shift->opt_cmdlineref
+}
+
# Class cmdline Options
sub opt_format {
return {
@@ -11141,12 +11154,12 @@ sub opt_format {
};
}
-sub BUILD {
- my $self = shift;
- $self->opt($self->optref);
- $self->opt_file($self->opt_fileref);
- $self->opt_cmdline($self->opt_cmdlineref);
-}
+# sub BUILD {
+# my $self = shift;
+# $self->opt($self->optref);
+# $self->opt_file($self->opt_fileref);
+# $self->opt_cmdline($self->opt_cmdlineref);
+# }
# Use to bind a new options ref to the class global $optref var
sub setvar {
@@ -11535,7 +11548,7 @@ sub enable {
$self->save( $name, @options );
return 0;
}
-
+}
package gip::Singletons;
#This enforces singletons outside of the class
@@ -11552,5 +11565,4 @@ sub pvr {
$pvr
}
-
############## End OO ##############

0 comments on commit f464ed5

Please sign in to comment.