Skip to content
Browse files

refactored strip command

  • Loading branch information...
1 parent 676b10a commit 55413c4e8d473c20df81415a3d90a6a0babe8f64 @xdg xdg committed
Showing with 9 additions and 14 deletions.
  1. +9 −14 lib/Pantry/App/Command/rename.pm
View
23 lib/Pantry/App/Command/rename.pm
@@ -18,23 +18,18 @@ sub command_type {
return 'DUAL_TARGET';
}
-sub valid_types {
- return qw/node role environment/
-}
+my @types = qw/node role environment/;
-sub _rename_node {
- my ($self, $opt, $name, $dest) = @_;
- return $self->_rename_obj($opt, 'node', $name, $dest);
-}
-
-sub _rename_role {
- my ($self, $opt, $name, $dest) = @_;
- return $self->_rename_obj($opt, 'role', $name, $dest);
+sub valid_types {
+ return @types;
}
-sub _rename_environment {
- my ($self, $opt, $name, $dest) = @_;
- return $self->_rename_obj($opt, 'environment', $name, $dest);
+for my $t (@types) {
+ no strict 'refs';
+ *{"_rename_$t"} = sub {
+ my ($self, $opt, $name, $dest) = @_;
+ return $self->_rename_obj($opt, $t, $name, $dest);
+ };
}
sub _rename_obj {

0 comments on commit 55413c4

Please sign in to comment.
Something went wrong with that request. Please try again.