Refactor code to force assets to always be hidden into a role and use it.
This commit is contained in:
parent
1d777d4596
commit
abaeab36e0
8 changed files with 71 additions and 52 deletions
|
|
@ -133,14 +133,7 @@ property userDefined5 => (
|
|||
default => '',
|
||||
);
|
||||
|
||||
around isHidden => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_ > 0) {
|
||||
$_[0] = 1;
|
||||
}
|
||||
$self->$orig(@_);
|
||||
};
|
||||
with 'WebGUI::AssetRole::AlwaysHidden';
|
||||
|
||||
use WebGUI::DateTime;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,15 +39,7 @@ for my $i ( 1 .. 5 ) {
|
|||
);
|
||||
}
|
||||
|
||||
around isHidden => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_ > 0) {
|
||||
$_[0] = 1;
|
||||
}
|
||||
$self->$orig(@_);
|
||||
};
|
||||
|
||||
with 'WebGUI::AssetRole::AlwaysHidden';
|
||||
|
||||
use Carp qw( croak confess );
|
||||
use URI::Escape;
|
||||
|
|
|
|||
|
|
@ -73,14 +73,7 @@ property content => (
|
|||
default => undef,
|
||||
);
|
||||
|
||||
around isHidden => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_ > 0) {
|
||||
$_[0] = 1;
|
||||
}
|
||||
$self->$orig(@_);
|
||||
};
|
||||
with 'WebGUI::AssetRole::AlwaysHidden';
|
||||
|
||||
sub _set_ownerUserId {
|
||||
my ($self, $new, $old) = @_;
|
||||
|
|
|
|||
|
|
@ -67,15 +67,7 @@ property photo => (
|
|||
noFormPost => 1,
|
||||
);
|
||||
|
||||
around isHidden => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_ > 0) {
|
||||
$_[0] = 1;
|
||||
}
|
||||
$self->$orig(@_);
|
||||
};
|
||||
|
||||
with 'WebGUI::AssetRole::AlwaysHidden';
|
||||
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::International;
|
||||
|
|
|
|||
|
|
@ -55,14 +55,7 @@ property isFeatured => (
|
|||
noFormPost => 1,
|
||||
);
|
||||
|
||||
around isHidden => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_ > 0) {
|
||||
$_[0] = 1;
|
||||
}
|
||||
$self->$orig(@_);
|
||||
};
|
||||
with 'WebGUI::AssetRole::AlwaysHidden';
|
||||
|
||||
use WebGUI::International;
|
||||
use WebGUI::Utility;
|
||||
|
|
|
|||
|
|
@ -41,15 +41,7 @@ for my $i ( 1 .. 5 ) {
|
|||
);
|
||||
}
|
||||
|
||||
around isHidden => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_ > 0) {
|
||||
$_[0] = 1;
|
||||
}
|
||||
$self->$orig(@_);
|
||||
};
|
||||
|
||||
with 'WebGUI::AssetRole::AlwaysHidden';
|
||||
|
||||
use Carp qw( croak );
|
||||
use File::Find;
|
||||
|
|
|
|||
45
lib/WebGUI/AssetRole/AlwaysHidden.pm
Normal file
45
lib/WebGUI/AssetRole/AlwaysHidden.pm
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package WebGUI::AssetRole::AlwaysHidden;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetRole::AlwaysHidden
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Asset Role that guarantees that the isHidden property is always 1.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
with WebGUI::AssetRole::AlwaysHidden;
|
||||
|
||||
=cut
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
around isHidden => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_ > 0) {
|
||||
shift @_;
|
||||
unshift @_, 1;
|
||||
}
|
||||
$self->$orig(@_);
|
||||
};
|
||||
|
||||
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue