From f974534e226c84ba58e631c2a77e65556178787e Mon Sep 17 00:00:00 2001 From: Maarten Vanraes Date: Sat, 14 May 2016 15:05:50 +0200 Subject: make a PartitionElement part and define restrictions for PartLink --- .../Shared/disk_backend/Plugin/Partition.pm | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'lib') 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; -- cgit v1.2.1