-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Moose] ConfigOB - grepping the boolean config settings using ConfigOB #500
Changes from 4 commits
616213e
307a996
952ee31
80f6f50
431a698
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,10 @@ use constant LOOK_UP_CENTER_NAME_USING => 'lookupCenterNameUsing'; | |
use constant DEFACING_REF_SCAN_TYPE => 'reference_scan_type_for_defacing'; | ||
use constant LEGO_PHANTOM_REGEX => 'LegoPhantomRegex'; | ||
use constant LIVING_PHANTOM_REGEX => 'LivingPhantomRegex'; | ||
use constant CREATE_NII => 'create_nii'; | ||
use constant HORIZONTAL_PICS => 'horizontalPics'; | ||
use constant IS_QSUB => 'is_qsub'; | ||
use constant CREATE_CANDIDATES => 'createCandidates'; | ||
|
||
=pod | ||
|
||
|
@@ -139,6 +143,23 @@ my $getConfigSettingRef = sub { | |
return $result->[0]->{'value'}; | ||
}; | ||
|
||
|
||
=head3 &$getBoolean($value) | ||
nicolasbrossard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Private method. This methods returns 1 if a boolean value is set to either 'true' | ||
nicolasbrossard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
or '1'; 0 otherwise. This ensures harmonization of the boolean settings. | ||
|
||
INPUT: boolean value extracted from the Config table | ||
|
||
RETURN: 1 if the value provided is 'true' or '1'; 0 otherwise | ||
|
||
=cut | ||
my $getBoolean = sub { | ||
my ($value) = @_; | ||
|
||
return ($value eq "true" || $value == 1) ? 1 : 0; | ||
}; | ||
|
||
=head3 getTarchiveLibraryDir() | ||
|
||
Gets the tarchive library dir. | ||
|
@@ -348,6 +369,66 @@ sub getLivingPhantomRegex { | |
return &$getConfigSettingRef($self, LIVING_PHANTOM_REGEX); | ||
} | ||
|
||
=head3 getCreateNii() | ||
|
||
Get the create_nii Config setting. | ||
|
||
RETURN: (boolean) 1 if create_nii is set to Yes in the Config module, 0 otherwise | ||
|
||
=cut | ||
sub getCreateNii { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be a good idea to have a private function Oh and here's how you declare/used a private function:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree! |
||
my $self = shift; | ||
|
||
my $value = &$getConfigSettingRef($self, CREATE_NII); | ||
|
||
return $getBoolean->($value); | ||
} | ||
|
||
=head3 getHorizontalPics() | ||
|
||
Get the horizontalPics Config setting. | ||
|
||
RETURN: (boolean) 1 if horizontalPics is set to Yes in the Config module, 0 otherwise | ||
|
||
=cut | ||
sub getHorizontalPics { | ||
my $self = shift; | ||
|
||
my $value = &$getConfigSettingRef($self, HORIZONTAL_PICS); | ||
|
||
return $getBoolean->($value); | ||
} | ||
|
||
=head3 getIsQsub() | ||
|
||
Get the is_qsub Config setting. | ||
|
||
RETURN: (boolean) 1 if is_qsub is set to Yes in the Config module, 0 otherwise | ||
|
||
=cut | ||
sub getIsQsub { | ||
my $self = shift; | ||
|
||
my $value = &$getConfigSettingRef($self, IS_QSUB); | ||
|
||
return $getBoolean->($value); | ||
} | ||
|
||
=head3 getCreateCandidates() | ||
|
||
Get the createCandidates Config setting. | ||
|
||
RETURN: (boolean) 1 if createCandidates is set to Yes in the Config module, 0 otherwise | ||
|
||
=cut | ||
sub getCreateCandidates { | ||
my $self = shift; | ||
|
||
my $value = &$getConfigSettingRef($self, IS_QSUB); | ||
|
||
return $getBoolean->($value); | ||
} | ||
|
||
1; | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to instantiate
$configOB
again: it was already defined on line 1585. Also, the definition of$createCandidates
should go here instead of further up.