Skip to content

Commit

Permalink
Fix for PerlDancer#108 and PerlDancer#111. Reverting back to using Cl…
Browse files Browse the repository at this point in the history
…one instead of

Storable::dclone. auto_reload now requires both Module::Refresh
and Clone.
  • Loading branch information
ironcamel committed Sep 2, 2010
1 parent 529eaf4 commit dcd930b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
9 changes: 6 additions & 3 deletions lib/Dancer/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ sub routes {
sub reload_apps {
my ($class) = @_;

if (Dancer::ModuleLoader->load('Module::Refresh')) {
my @missing_modules = grep { not Dancer::ModuleLoader->load($_) }
qw(Module::Refresh Clone);

if (not @missing_modules) {

# saving apps & purging app registries
my $orig_apps = {};
Expand All @@ -63,8 +66,8 @@ sub reload_apps {

}
else {
warn "Module::Refresh is not installed, "
. "install this module or unset 'auto_reload' in your config file";
warn "Modules required for auto_reload are missing. Install modules"
. " [@missing_modules] or unset 'auto_reload' in your config file.";
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Dancer/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ $public/$error_code.html if it exists.
=head2 auto_reload (boolean)
Requires L<Module::Refresh>.
Requires L<Module::Refresh> and L<Clone>.
If set to true, Dancer will reload the route handlers whenever the file where
they are defined is changed. This is very useful in development environment but
Expand Down
11 changes: 3 additions & 8 deletions lib/Dancer/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ package Dancer::Object;

use strict;
use warnings;
use Storable 'dclone';
{ # We have to set $Deparse and $Eval to be able to clone objects that contain
# coderefs http://p3rl.org/Storable#CODE_REFERENCES
no warnings 'once';
$Storable::Deparse = 1;
$Storable::Eval = 1;
}

# constructor
sub new {
Expand All @@ -24,7 +17,9 @@ sub new {

sub clone {
my ($self) = @_;
return dclone($self);
die "The 'Clone' module is needed"
unless Dancer::ModuleLoader->load('Clone');
return Clone::clone($self);
}

# initializer
Expand Down
2 changes: 1 addition & 1 deletion script/dancer
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ my $DO_OVERWRITE_ALL = 0;
my $DANCER_APP_DIR = get_application_path($path, $name);
my $DANCER_SCRIPT = get_script_path($name);
my ($LIB_FILE, $LIB_PATH) = get_lib_path($name);
my $AUTO_RELOAD = eval "require Module::Refresh" ? 1 : 0;
my $AUTO_RELOAD = eval "require Module::Refresh and require Clone" ? 1 : 0;

require Dancer;
my $DANCER_VERSION = $Dancer::VERSION;
Expand Down

0 comments on commit dcd930b

Please sign in to comment.