aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaarten Vanraes <alien@mageia.org>2016-05-14 15:05:50 +0200
committerMaarten Vanraes <alien@mageia.org>2016-05-14 15:05:50 +0200
commitf974534e226c84ba58e631c2a77e65556178787e (patch)
treef6e894b5ebcc1cbb37a26fcf7d13a9cf8fd23824 /lib
parentc675b0e1da78bfef29149fdb18b2ecfb37c3e839 (diff)
downloadmanatools-f974534e226c84ba58e631c2a77e65556178787e.tar
manatools-f974534e226c84ba58e631c2a77e65556178787e.tar.gz
manatools-f974534e226c84ba58e631c2a77e65556178787e.tar.bz2
manatools-f974534e226c84ba58e631c2a77e65556178787e.tar.xz
manatools-f974534e226c84ba58e631c2a77e65556178787e.zip
make a PartitionElement part and define restrictions for PartLink
Diffstat (limited to 'lib')
-rw-r--r--lib/ManaTools/Shared/disk_backend/Plugin/Partition.pm61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/disk_backend/Plugin/Partition.pm b/lib/ManaTools/Shared/disk_backend/Plugin/Partition.pm
index c2977fe6..b6f5a3d8 100644
--- a/lib/ManaTools/Shared/disk_backend/Plugin/Partition.pm
+++ b/lib/ManaTools/Shared/disk_backend/Plugin/Partition.pm
@@ -211,6 +211,26 @@ class_has '+type' => (
default => 'PartitionTable'
);
+class_has '+restrictions' => (
+ default => sub {
+ return {
+ child => sub {
+ my $self = shift;
+ my $part = shift;
+ return $part->isa('ManaTools::Shared::disk_backend::Part::PartitionElement');
+ },
+ parent => sub {
+ my $self = shift;
+ my $part = shift;
+ return $part->does('ManaTools::Shared::disk_backend::BlockDevice');
+ },
+ sibling => sub { return 0; },
+ previous => sub { return 0; },
+ next => sub { return 0; },
+ }
+ }
+);
+
class_has '+in_restriction' => (
default => sub {
return sub {
@@ -245,4 +265,45 @@ class_has '+out_restriction' => (
}
);
+package ManaTools::Shared::disk_backend::Part::PartitionElement;
+
+use Moose;
+
+extends 'ManaTools::Shared::disk_backend::Part';
+
+with 'ManaTools::Shared::disk_backend::BlockDevice';
+
+use MooseX::ClassAttribute;
+
+class_has '+type' => (
+ default => 'PartitionElement'
+);
+
+class_has '+restrictions' => (
+ default => sub {
+ return {
+ parent => sub {
+ my $self = shift;
+ my $part = shift;
+ return $part->isa('ManaTools::Shared::disk_backend::Part::PartitionTable');
+ },
+ sibling => sub {
+ my $self = shift;
+ my $part = shift;
+ return $part->isa('ManaTools::Shared::disk_backend::Part::PartitionElement');
+ },
+ previous => sub {
+ my $self = shift;
+ my $part = shift;
+ return $part->isa('ManaTools::Shared::disk_backend::Part::PartitionElement');
+ },
+ next => sub {
+ my $self = shift;
+ my $part = shift;
+ return $part->isa('ManaTools::Shared::disk_backend::Part::PartitionElement');
+ },
+ }
+ }
+);
+
1;